Exposing also the `IsFinite` one. Unit testing both operations.tags/v0.12
| @@ -57,6 +57,12 @@ namespace Tensorflow | |||||
| public static Tensor arg_min(Tensor input, int dimension, TF_DataType output_type = TF_DataType.TF_INT64, string name = null) | public static Tensor arg_min(Tensor input, int dimension, TF_DataType output_type = TF_DataType.TF_INT64, string name = null) | ||||
| => gen_math_ops.arg_min(input, dimension, output_type: output_type, name: name); | => gen_math_ops.arg_min(input, dimension, output_type: output_type, name: name); | ||||
| public static Tensor is_finite(Tensor input, string name = null) | |||||
| => gen_math_ops.is_finite(input, name); | |||||
| public static Tensor is_nan(Tensor input, string name = null) | |||||
| => gen_math_ops.is_nan(input, name); | |||||
| /// <summary> | /// <summary> | ||||
| /// Returns element-wise smallest integer not less than x. | /// Returns element-wise smallest integer not less than x. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -376,6 +376,13 @@ namespace Tensorflow | |||||
| return _op.outputs[0]; | return _op.outputs[0]; | ||||
| } | } | ||||
| public static Tensor is_nan(Tensor x, string name = null) | |||||
| { | |||||
| var _op = _op_def_lib._apply_op_helper("IsNan", name: name, args: new { x }); | |||||
| return _op.outputs[0]; | |||||
| } | |||||
| /// <summary> | /// <summary> | ||||
| /// Computes exponential of x element-wise. \\(y = e^x\\). | /// Computes exponential of x element-wise. \\(y = e^x\\). | ||||
| /// </summary> | /// </summary> | ||||
| @@ -61,6 +61,34 @@ namespace TensorFlowNET.UnitTest | |||||
| } | } | ||||
| } | } | ||||
| [TestMethod] | |||||
| public void isFinite() | |||||
| { | |||||
| var a = tf.constant(new[] { 1, np.nan, 2, np.nan, 3, np.nan, 4, np.nan }); | |||||
| var b = tf.cast(tf.is_finite(a), tf.float32); | |||||
| var check = np.array(1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f); | |||||
| using (var sess = tf.Session()) | |||||
| { | |||||
| var o = sess.run(b); | |||||
| Assert.IsTrue(o.array_equal(check)); | |||||
| } | |||||
| } | |||||
| [TestMethod] | |||||
| public void isNan() | |||||
| { | |||||
| var a = tf.constant(new[] { 1, np.nan, 2, np.nan, 3, np.nan, 4, np.nan }); | |||||
| var b = tf.cast(tf.is_nan(a), tf.float32); | |||||
| var check = np.array(0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f); | |||||
| using (var sess = tf.Session()) | |||||
| { | |||||
| var o = sess.run(b); | |||||
| Assert.IsTrue(o.array_equal(check)); | |||||
| } | |||||
| } | |||||
| [TestMethod] | [TestMethod] | ||||
| public void addOpTests() | public void addOpTests() | ||||
| { | { | ||||