Browse Source

add tf.math.sigmoid

tags/v0.9
Oceania2018 6 years ago
parent
commit
3c7174b702
4 changed files with 31 additions and 2 deletions
  1. +3
    -0
      src/TensorFlowNET.Core/APIs/tf.math.cs
  2. +20
    -0
      src/TensorFlowNET.Core/Operations/gen_math_ops.cs
  3. +7
    -1
      src/TensorFlowNET.Core/Operations/math_ops.cs
  4. +1
    -1
      test/TensorFlowNET.UnitTest/PythonTest.cs

+ 3
- 0
src/TensorFlowNET.Core/APIs/tf.math.cs View File

@@ -281,6 +281,9 @@ namespace Tensorflow
return math_ops.reduce_sum(input, axis);
}

public static Tensor sigmoid<T>(T x, string name = null)
=> math_ops.sigmoid(x, name: name);

public static Tensor sum(Tensor input, int axis, bool keep_dims = false, string name = null)
=> gen_math_ops._sum(input, axis, keep_dims: keep_dims, name: name);



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

@@ -108,6 +108,26 @@ namespace Tensorflow
return _op.outputs[0];
}
/// <summary>
/// Computes sigmoid of <c>x</c> element-wise.
/// </summary>
/// <param name="x">
/// </param>
/// <param name="name">
/// If specified, the created operation in the graph will be this one, otherwise it will be named 'Sigmoid'.
/// </param>
/// <returns>
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result.
/// </returns>
/// <remarks>
/// Specifically, <c>y = 1 / (1 + exp(-x))</c>.
/// </remarks>
public static Tensor sigmoid(Tensor x, string name = "Sigmoid")
{
var op = _op_def_lib._apply_op_helper("Sigmoid", name: name, new { x });
return op.output;
}
public static Tensor sinh(Tensor x, string name = null)
{
var _op = _op_def_lib._apply_op_helper("Sinh", name, args: new { x });


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

@@ -119,7 +119,13 @@ namespace Tensorflow
return _may_reduce_to_scalar(keepdims, axis, m);
}
}

public static Tensor sigmoid<T>(T x, string name = null)
{
var x_tensor = ops.convert_to_tensor(x, name: "x");
return gen_math_ops.sigmoid(x_tensor, name: name);
}

/// <summary>
/// Returns (x - y)(x - y) element-wise.
/// </summary>


+ 1
- 1
test/TensorFlowNET.UnitTest/PythonTest.cs View File

@@ -143,7 +143,7 @@ namespace TensorFlowNET.UnitTest
// return self._eval_helper(tensors)
// else:
{
with(ops.get_default_session(), s =>
with(tf.Session(), s =>
{
var ndarray=tensor.eval();
if (typeof(T) == typeof(double))


Loading…
Cancel
Save