Browse Source

minor change in CondTestCases to assert that the original structure of the python tests works too (with session is not needed due to use of PythonTest.evaluate()

tags/v0.9
Meinrad Recheis 6 years ago
parent
commit
fc5131d00a
1 changed files with 22 additions and 28 deletions
  1. +22
    -28
      test/TensorFlowNET.UnitTest/control_flow_ops_test/CondTestCases.cs

+ 22
- 28
test/TensorFlowNET.UnitTest/control_flow_ops_test/CondTestCases.cs View File

@@ -19,10 +19,10 @@ namespace TensorFlowNET.UnitTest.control_flow_ops_test
with(tf.Session(graph), sess =>
{
var x = tf.constant(2, name: "x");
var y = tf.constant(5, name: "y");
var y = tf.constant(5, name: "y");
var z = control_flow_ops.cond(tf.less(x, y),
() => tf.constant(22, name: "t22"),
var z = control_flow_ops.cond(tf.less(x, y),
() => tf.constant(22, name: "t22"),
() => tf.constant(55, name: "f55"));
int result = z.eval(sess);
@@ -40,8 +40,8 @@ namespace TensorFlowNET.UnitTest.control_flow_ops_test
var x = tf.constant(2, name: "x");
var y = tf.constant(1, name: "y");
var z = control_flow_ops.cond(tf.less(x, y),
() => tf.constant(22, name: "t22"),
var z = control_flow_ops.cond(tf.less(x, y),
() => tf.constant(22, name: "t22"),
() => tf.constant(11, name: "f11"));
int result = z.eval(sess);
@@ -52,42 +52,36 @@ namespace TensorFlowNET.UnitTest.control_flow_ops_test
[TestMethod]
public void testCondTrue()
{
var graph = tf.Graph().as_default();
tf.Graph().as_default();
with(tf.Session(graph), sess =>
{
var x = tf.constant(2, name: "x");
var y = tf.constant(5, name: "y");
var x = tf.constant(2, name: "x");
var y = tf.constant(5, name: "y");
var z = control_flow_ops.cond(tf.less(x, y),
() => tf.multiply(x, 17),
() => tf.add(y, 23));
var z = control_flow_ops.cond(tf.less(x, y),
() => tf.multiply(x, 17),
() => tf.add(y, 23));
int result = z.eval(sess);
assertEquals(result, 34);
});
var result = evaluate<int>(z);
assertEquals(result, 34);
}
[TestMethod]
public void testCondFalse()
{
var graph = tf.Graph().as_default();
tf.Graph().as_default();
with(tf.Session(graph), sess =>
{
var x = tf.constant(2);
var y = tf.constant(1);
var x = tf.constant(2);
var y = tf.constant(1);
var z = control_flow_ops.cond(tf.less(x, y),
() => tf.multiply(x, 17),
() => tf.add(y, 23));
var z = control_flow_ops.cond(tf.less(x, y),
() => tf.multiply(x, 17),
() => tf.add(y, 23));
int result = z.eval(sess);
assertEquals(result, 24);
});
var result = evaluate<int>(z);
assertEquals(result, 24);
}
// NOTE: all other test python test cases of this class are either not needed due to strong typing or dest a deprecated api
// NOTE: all other python test cases of this class are either not needed due to strong typing or test a deprecated api
}
}

Loading…
Cancel
Save