@@ -23,6 +23,15 @@ namespace Tensorflow | |||||
{ | { | ||||
public Tensor log(Tensor x, string name = null) | public Tensor log(Tensor x, string name = null) | ||||
=> gen_math_ops.log(x, name); | => gen_math_ops.log(x, name); | ||||
/// <summary> | |||||
/// Computes the Gauss error function of `x` element-wise. | |||||
/// </summary> | |||||
/// <param name="x"></param> | |||||
/// <param name="name"></param> | |||||
/// <returns></returns> | |||||
public Tensor erf(Tensor x, string name = null) | |||||
=> math_ops.erf(x, name); | |||||
} | } | ||||
public Tensor abs(Tensor x, string name = null) | public Tensor abs(Tensor x, string name = null) | ||||
@@ -265,6 +265,29 @@ namespace Tensorflow | |||||
public static Tensor equal<Tx, Ty>(Tx x, Ty y, string name = null) | public static Tensor equal<Tx, Ty>(Tx x, Ty y, string name = null) | ||||
=> gen_math_ops.equal(x, y, name: name); | => gen_math_ops.equal(x, y, name: name); | ||||
/// <summary> | |||||
/// Computes the Gauss error function of `x` element-wise. | |||||
/// </summary> | |||||
/// <param name="x"></param> | |||||
/// <param name="name"></param> | |||||
/// <returns></returns> | |||||
public static Tensor erf(Tensor x, string name = null) | |||||
=> tf.Context.RunInAutoMode2( | |||||
() => tf.OpDefLib._apply_op_helper("Erf", name, new { x }).output, | |||||
() => tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, | |||||
"Erf", name, | |||||
null, | |||||
x).FirstOrDefault(), | |||||
(op) => | |||||
{ | |||||
var attrs = new object[] | |||||
{ | |||||
"T", op.get_attr<TF_DataType>("T") | |||||
}; | |||||
tf.Runner.RecordGradient("Erf", op.inputs, attrs, op.outputs); | |||||
}, | |||||
new Tensors(x)); | |||||
public static Tensor sqrt(Tensor x, string name = null) | public static Tensor sqrt(Tensor x, string name = null) | ||||
=> gen_math_ops.sqrt(x, name: name); | => gen_math_ops.sqrt(x, name: name); | ||||
@@ -48,5 +48,14 @@ namespace TensorFlowNET.UnitTest.ManagedAPI | |||||
var x5 = tf.reduce_sum(b, (0, 1)); | var x5 = tf.reduce_sum(b, (0, 1)); | ||||
Assert.AreEqual(-4.7f, (float)x5); | Assert.AreEqual(-4.7f, (float)x5); | ||||
} | } | ||||
[TestMethod] | |||||
public void Erf() | |||||
{ | |||||
var erf = tf.math.erf(a, name: "erf"); | |||||
var expected = new float[] { 0.8427007f, -0.5204999f, 0.99999845f, -0.9970206f, 0f, -1f }; | |||||
var actual = erf.ToArray<float>(); | |||||
Assert.IsTrue(Equal(expected, actual)); | |||||
} | |||||
} | } | ||||
} | } |