Beispiel #1
0
 def test_constant(self):
   for v in [True, False, 1, 0, 1.0]:
     c = constant_op.constant(v)
     value = utils.constant_value(c)
     self.assertEqual(value, v)
     with self.cached_session():
       self.assertEqual(c.eval(), v)
Beispiel #2
0
 def test_placeholder(self):
   for v in [True, False, 1, 0, 1.0]:
     p = array_ops.placeholder(np.dtype(type(v)), [])
     x = array_ops.identity(p)
     value = utils.constant_value(p)
     self.assertEqual(value, None)
     with self.cached_session():
       self.assertEqual(x.eval(feed_dict={p: v}), v)
Beispiel #3
0
 def test_variable(self):
   for v in [True, False, 1, 0, 1.0]:
     with ops.Graph().as_default() as g, self.session(g) as sess:
       x = variables.Variable(v)
       value = utils.constant_value(x)
       self.assertEqual(value, None)
       sess.run(variables.global_variables_initializer())
       self.assertEqual(x.eval(), v)
Beispiel #4
0
 def test_value(self):
   for v in [True, False, 1, 0, 1.0]:
     value = utils.constant_value(v)
     self.assertEqual(value, v)