diff --git a/src/TensorFlowNET.Core/Gradients/gradients_impl.py.cs b/src/TensorFlowNET.Core/Gradients/gradients_impl.py.cs index 71801385..046732c1 100644 --- a/src/TensorFlowNET.Core/Gradients/gradients_impl.py.cs +++ b/src/TensorFlowNET.Core/Gradients/gradients_impl.py.cs @@ -129,15 +129,23 @@ namespace Tensorflow // for ops that do not have gradients. var grad_fn = ops.get_gradient_function(op); - Python.with(new ops.name_scope(op.Name + "_grad"), delegate + Python.with(new ops.name_scope(op.Name + "_grad"), scope1 => { + string name1 = scope1; if (grad_fn != null) { in_grads = _MaybeCompile(grad_scope, op, out_grads[0], null, grad_fn); _VerifyGeneratedGradients(in_grads, op); } + + if (gate_gradients) + { + + } }); - + + // temp fix name scope + op.Graph._name_stack = "gradients"; } } else diff --git a/src/TensorFlowNET.Core/Operations/OpDefLibrary.cs b/src/TensorFlowNET.Core/Operations/OpDefLibrary.cs index 3b30a12b..98fd6e09 100644 --- a/src/TensorFlowNET.Core/Operations/OpDefLibrary.cs +++ b/src/TensorFlowNET.Core/Operations/OpDefLibrary.cs @@ -93,6 +93,8 @@ namespace Tensorflow foreach (var attr_def in op_def.Attr) { var key = attr_def.Name; + if (!attrs.ContainsKey(key)) + Console.WriteLine($"{key} not found in attr_def."); var value = attrs[key]; var attr_value = new AttrValue(); diff --git a/src/TensorFlowNET.Core/Operations/array_ops.py.cs b/src/TensorFlowNET.Core/Operations/array_ops.py.cs index 2753853e..df139aa3 100644 --- a/src/TensorFlowNET.Core/Operations/array_ops.py.cs +++ b/src/TensorFlowNET.Core/Operations/array_ops.py.cs @@ -99,7 +99,7 @@ namespace Tensorflow // result = gen_array_ops.shape(); } - return null; + return gen_array_ops.shape(input); }); } diff --git a/src/TensorFlowNET.Core/Operations/gen_array_ops.cs b/src/TensorFlowNET.Core/Operations/gen_array_ops.cs index 77e9136f..5cbe56ce 100644 --- a/src/TensorFlowNET.Core/Operations/gen_array_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_array_ops.cs @@ -80,6 +80,12 @@ namespace Tensorflow return _op.outputs[0]; } + public static Tensor shape(Tensor input, TF_DataType out_type = TF_DataType.TF_INT32, string name = "") + { + var _op = _op_def_lib._apply_op_helper("Shape", name, new { input, out_type }); + return _op.outputs[0]; + } + public static Tensor size(Tensor input, TF_DataType out_type = TF_DataType.TF_INT32, string name = "") { var _op = _op_def_lib._apply_op_helper("Size", name, new { input, out_type }); diff --git a/src/TensorFlowNET.Core/Operations/gen_math_ops.cs b/src/TensorFlowNET.Core/Operations/gen_math_ops.cs index 140e8e29..ce4ae2a7 100644 --- a/src/TensorFlowNET.Core/Operations/gen_math_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_math_ops.cs @@ -45,6 +45,13 @@ namespace Tensorflow return _op.outputs[0]; } + public static Tensor floor_mod(Tensor x, Tensor y, string name = "") + { + var _op = _op_def_lib._apply_op_helper("FloorMod", name, args: new { x, y }); + + return _op.outputs[0]; + } + /// /// Multiply the matrix "a" by the matrix "b". /// diff --git a/src/TensorFlowNET.Core/Operations/math_ops.py.cs b/src/TensorFlowNET.Core/Operations/math_ops.py.cs index 05893d54..94f16c23 100644 --- a/src/TensorFlowNET.Core/Operations/math_ops.py.cs +++ b/src/TensorFlowNET.Core/Operations/math_ops.py.cs @@ -19,6 +19,7 @@ namespace Tensorflow var input_rank = array_ops.size(input_shape); axes = (axes + input_rank) % input_rank; + var axes_shape = array_ops.shape(axes); return null; } diff --git a/src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs b/src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs index 2cf600f7..332c0d70 100644 --- a/src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs +++ b/src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs @@ -79,7 +79,10 @@ namespace Tensorflow public static Tensor operator %(Tensor x, Tensor y) { - throw new NotImplementedException("math mod is not implemented"); + return Python.with(new ops.name_scope("", "mod", new object[] { x, y }), scope => + { + return gen_math_ops.floor_mod(x, y, scope); + }); } } } diff --git a/src/TensorFlowNET.Core/Tensors/TensorShape.cs b/src/TensorFlowNET.Core/Tensors/TensorShape.cs index e63543d6..4f45bfbe 100644 --- a/src/TensorFlowNET.Core/Tensors/TensorShape.cs +++ b/src/TensorFlowNET.Core/Tensors/TensorShape.cs @@ -23,7 +23,7 @@ namespace Tensorflow /// public bool is_fully_defined() { - return Dimensions != null && Dimensions.Count(x => x > 0) > 0; + return Dimensions != null && Dimensions.Count(x => x < 1) == 0; } } }