Browse Source

gen_math_ops.floor_mod #160

tags/v0.8.0
haiping008 6 years ago
parent
commit
f1898385c2
8 changed files with 32 additions and 5 deletions
  1. +10
    -2
      src/TensorFlowNET.Core/Gradients/gradients_impl.py.cs
  2. +2
    -0
      src/TensorFlowNET.Core/Operations/OpDefLibrary.cs
  3. +1
    -1
      src/TensorFlowNET.Core/Operations/array_ops.py.cs
  4. +6
    -0
      src/TensorFlowNET.Core/Operations/gen_array_ops.cs
  5. +7
    -0
      src/TensorFlowNET.Core/Operations/gen_math_ops.cs
  6. +1
    -0
      src/TensorFlowNET.Core/Operations/math_ops.py.cs
  7. +4
    -1
      src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs
  8. +1
    -1
      src/TensorFlowNET.Core/Tensors/TensorShape.cs

+ 10
- 2
src/TensorFlowNET.Core/Gradients/gradients_impl.py.cs View File

@@ -129,15 +129,23 @@ namespace Tensorflow
// for ops that do not have gradients.
var grad_fn = ops.get_gradient_function(op);

Python.with<ops.name_scope>(new ops.name_scope(op.Name + "_grad"), delegate
Python.with<ops.name_scope>(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


+ 2
- 0
src/TensorFlowNET.Core/Operations/OpDefLibrary.cs View File

@@ -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();



+ 1
- 1
src/TensorFlowNET.Core/Operations/array_ops.py.cs View File

@@ -99,7 +99,7 @@ namespace Tensorflow
// result = gen_array_ops.shape();
}

return null;
return gen_array_ops.shape(input);
});
}



+ 6
- 0
src/TensorFlowNET.Core/Operations/gen_array_ops.cs View File

@@ -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 });


+ 7
- 0
src/TensorFlowNET.Core/Operations/gen_math_ops.cs View File

@@ -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];
}

/// <summary>
/// Multiply the matrix "a" by the matrix "b".
/// </summary>


+ 1
- 0
src/TensorFlowNET.Core/Operations/math_ops.py.cs View File

@@ -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;
}


+ 4
- 1
src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs View File

@@ -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<ops.name_scope, Tensor>(new ops.name_scope("", "mod", new object[] { x, y }), scope =>
{
return gen_math_ops.floor_mod(x, y, scope);
});
}
}
}

+ 1
- 1
src/TensorFlowNET.Core/Tensors/TensorShape.cs View File

@@ -23,7 +23,7 @@ namespace Tensorflow
/// <returns></returns>
public bool is_fully_defined()
{
return Dimensions != null && Dimensions.Count(x => x > 0) > 0;
return Dimensions != null && Dimensions.Count(x => x < 1) == 0;
}
}
}

Loading…
Cancel
Save