def test_assign_add(self): x = tensor.Variable(GraphInfo('x', 'scope', False), initializer=1) y = x.assign_add(10) with self.variables_initialized_test_session() as sess: assert sess.run(x.data) == 1 assert sess.run(y.data) == 11 assert sess.run(x.data) == 11
def test_construct_by_graph_info_name(self): x = tensor.Variable(GraphInfo('x', 'scope', False), initializer=0) assert x.data.name == 'scope/x:0'
def test_construct_by_graph_info_value(self): x = tensor.Variable(GraphInfo('x', 'scope', False), initializer=0) with self.variables_initialized_test_session() as sess: assert sess.run(x.data) == 0
def test_basic(self): x_ = np.array([1.0, 2.0, 3.0], np.float32) x = tensor.Variable(GraphInfo('x'), initializer=x_) with self.variables_initialized_test_session() as sess: self.assertAllEqual(x.eval(), [1.0, 2.0, 3.0])
def test_init_constant(self): x = tensor.Variable('x', [], tf.float32, 1.0) with self.variables_initialized_test_session() as sess: self.assertAllEqual(x.eval(), 1.0)
def test_in_scope_name(self): with tf.variable_scope('scope'): x = tensor.Variable('x', [], tf.float32) assert x.data.name == 'scope/x:0'
def test_name(self): x = tensor.Variable('x', [], tf.float32) assert x.data.name == 'x:0'
def test_make_info(self): x = tensor.Variable('x', [], tf.float32) self.assertNameEqual(x.info, 'x') assert x.info.scope.name == ''