diff --git a/src/TensorFlowNET.Core/Operations/gen_math_ops.cs b/src/TensorFlowNET.Core/Operations/gen_math_ops.cs index e21b5b33..6e95bc70 100644 --- a/src/TensorFlowNET.Core/Operations/gen_math_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_math_ops.cs @@ -19,5 +19,16 @@ namespace Tensorflow return new Tensor(_op, 0, _op.OutputType(0)); } + + public static Tensor mul(Tensor x, Tensor y) + { + var keywords = new Dictionary(); + keywords.Add("x", x); + keywords.Add("y", y); + + var _op = _op_def_lib._apply_op_helper("Mul", name: "mul", keywords: keywords); + + return new Tensor(_op, 0, _op.OutputType(0)); + } } } diff --git a/src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs b/src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs index 28678d73..2653a9e0 100644 --- a/src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs +++ b/src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs @@ -10,5 +10,10 @@ namespace Tensorflow { return gen_math_ops.add(t1, t2); } + + public static Tensor operator *(Tensor t1, Tensor t2) + { + return gen_math_ops.mul(t1, t2); + } } } diff --git a/test/TensorFlowNET.Examples/BasicOperations.cs b/test/TensorFlowNET.Examples/BasicOperations.cs index 556017f9..9ec287f9 100644 --- a/test/TensorFlowNET.Examples/BasicOperations.cs +++ b/test/TensorFlowNET.Examples/BasicOperations.cs @@ -18,13 +18,13 @@ namespace TensorFlowNET.Examples // of the Constant op. var a = tf.constant(2); var b = tf.constant(3); - + var c = a * b; // Launch the default graph. using (var sess = tf.Session()) { Console.WriteLine("a=2, b=3"); Console.WriteLine($"Addition with constants: {sess.run(a + b)}"); - //Console.WriteLine($"Multiplication with constants: {sess.run(a * b)}"); + Console.WriteLine($"Multiplication with constants: {sess.run(a * b)}"); } } }