Browse Source

fixed Repeated Abs name #442

tags/v0.13
Oceania2018 6 years ago
parent
commit
5808e34ff7
5 changed files with 35 additions and 19 deletions
  1. +4
    -1
      src/TensorFlowNET.Core/APIs/tf.math.cs
  2. +5
    -0
      src/TensorFlowNET.Core/Operations/Operation.cs
  3. +3
    -10
      src/TensorFlowNET.Core/Operations/gen_math_ops.cs
  4. +20
    -3
      src/TensorFlowNET.Core/Operations/math_ops.cs
  5. +3
    -5
      src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs

+ 4
- 1
src/TensorFlowNET.Core/APIs/tf.math.cs View File

@@ -441,7 +441,7 @@ namespace Tensorflow
return math_ops.reduce_sum(input, keepdims: keepdims, name: name);
}

public Tensor reduce_sum(Tensor input, int[] axis, int? reduction_indices = null,
public Tensor reduce_sum(Tensor input, TensorShape axis, int? reduction_indices = null,
bool keepdims = false, string name = null)
=> math_ops.reduce_sum(input, axis, keepdims: keepdims, name: name);

@@ -456,6 +456,9 @@ namespace Tensorflow
public Tensor reduce_max(Tensor input_tensor, int[] axis = null, bool keepdims = false, string name = null)
=> math_ops.reduce_max(input_tensor, axis, keepdims, name);

public Tensor reduce_max(Tensor input_tensor, int axis, bool keepdims = false, string name = null)
=> math_ops.reduce_max(input_tensor, axis, keepdims, name);

public Tensor reduce_min(Tensor input_tensor, int[] axis = null, bool keepdims = false, string name = null)
=> math_ops.reduce_min(input_tensor, axis, keepdims, name);



+ 5
- 0
src/TensorFlowNET.Core/Operations/Operation.cs View File

@@ -186,6 +186,11 @@ namespace Tensorflow
if (op_def == null)
op_def = g.GetOpDef(node_def.Op);
if (node_def.Name.Equals("learn_rate/cond/pred_id"))
{
}
var grouped_inputs = _reconstruct_sequence_inputs(op_def, inputs, node_def.Attr);
_handle = ops._create_c_op(g, node_def, grouped_inputs, control_input_ops.ToArray());
_is_stateful = op_def.IsStateful;


+ 3
- 10
src/TensorFlowNET.Core/Operations/gen_math_ops.cs View File

@@ -629,9 +629,9 @@ namespace Tensorflow
public static Tensor _abs(Tensor x, string name = null)
{
var _op = _op_def_lib._apply_op_helper("Abs", name, new { x });
var _op = _op_def_lib._apply_op_helper("Abs", name, args: new { x });
return _op.outputs[0];
return _op.output;
}
public static Tensor _any<Tx, Ty>(Tx input, Ty axis, bool keep_dims = false, string name = null)
@@ -662,14 +662,7 @@ namespace Tensorflow
return _op.outputs[0];
}
public static Tensor _sum(Tensor input, Tensor axis = null, bool keep_dims = false, string name = null)
{
var _op = _op_def_lib._apply_op_helper("Sum", name, args: new { input, reduction_indices = axis, keep_dims });
return _op.outputs[0];
}
public static Tensor _sum(Tensor input, int axis, bool keep_dims = false, string name = null)
public static Tensor _sum<Tx, Ty>(Tx input, Ty axis = default, bool keep_dims = false, string name = null)
{
var _op = _op_def_lib._apply_op_helper("Sum", name, args: new { input, reduction_indices = axis, keep_dims });


+ 20
- 3
src/TensorFlowNET.Core/Operations/math_ops.cs View File

@@ -31,6 +31,7 @@ namespace Tensorflow
{
return tf_with(ops.name_scope(name, "Abs", new { x }), scope =>
{
name = scope;
x = ops.convert_to_tensor(x, name: "x");
if (x.dtype.is_complex())
throw new NotImplementedException("math_ops.abs for dtype.is_complex");
@@ -379,6 +380,13 @@ namespace Tensorflow
return _may_reduce_to_scalar(keepdims, axis, max);
}

public static Tensor reduce_max(Tensor input_tensor, int axis, bool keepdims = false, string name = null)
{
var r = _ReductionDims(input_tensor, axis);
var max = gen_math_ops._max(input_tensor, r, keepdims, name);
return _may_reduce_to_scalar(keepdims, axis, max);
}

public static Tensor reduce_min(Tensor input_tensor, int[] axis = null, bool keepdims = false, string name = null)
{
var r = _ReductionDims(input_tensor, axis);
@@ -434,15 +442,14 @@ namespace Tensorflow

public static Tensor reduce_sum(Tensor input_tensor, int[] axis, bool keepdims = false, string name = null)
{
var r = _ReductionDims(input_tensor, axis);
var m = gen_math_ops._sum(input_tensor, r, keep_dims: keepdims, name: name);
var m = gen_math_ops._sum(input_tensor, axis, keep_dims: keepdims, name: name);
return _may_reduce_to_scalar(keepdims, axis, m);
}

public static Tensor reduce_sum(Tensor input_tensor, int axis, bool keepdims = false, string name = null)
{
var m = gen_math_ops._sum(input_tensor, axis, keep_dims: keepdims, name: name);
return _may_reduce_to_scalar(keepdims, new int[] { axis }, m);
return _may_reduce_to_scalar(keepdims, axis, m);
}

private static Tensor _may_reduce_to_scalar(bool keepdims, Tensor axis, Tensor output)
@@ -464,6 +471,11 @@ namespace Tensorflow
return output;
}

private static Tensor _may_reduce_to_scalar(bool keepdims, int axis, Tensor output)
{
return output;
}

private static Tensor _ReductionDims(Tensor x, Tensor axis)
{
if (axis != null)
@@ -477,6 +489,11 @@ namespace Tensorflow
}
}

private static int _ReductionDims(Tensor x, int axis)
{
return axis;
}

private static Tensor _ReductionDims(Tensor x, int[] axis)
{
if (axis != null)


+ 3
- 5
src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs View File

@@ -328,18 +328,16 @@ namespace Tensorflow
switch (name.ToLowerInvariant())
{
case "add":
result = gen_math_ops.add(x1, y1, name: scope);
result = math_ops.add(x1, y1, name: scope);
break;
case "div":
result = _intTfDataTypes.Contains(x1.dtype) || _intTfDataTypes.Contains(y1.dtype)
? gen_math_ops.floor_div(x1, y1, name: scope)
: gen_math_ops.real_div(x1, y1, name: scope);
result = math_ops.div(x1, y1, name: scope);
break;
case "floordiv":
result = gen_math_ops.floor_div(x1, y1, name: scope);
break;
case "truediv":
result = gen_math_ops.real_div(x1, y1, name: scope);
result = math_ops.truediv(x1, y1, name: scope);
break;
case "mul":
result = gen_math_ops.mul(x1, y1, name: scope);


Loading…
Cancel
Save