Ejemplo n.º 1
0
 def test_reshape_inputs(self):
     """Test that layers can automatically reshape inconsistent inputs."""
     value1 = np.random.uniform(size=(2, 3)).astype(np.float32)
     value2 = np.random.uniform(size=(1, 6, 1)).astype(np.float32)
     with self.test_session() as sess:
         out_tensor = Add()(tf.constant(value1), tf.constant(value2))
         result = out_tensor.eval()
         assert result.shape == (1, 6, 1)
         assert np.array_equal(value1.reshape((1, 6, 1)) + value2, result)
Ejemplo n.º 2
0
 def test_add(self):
   """Test that Add can be invoked."""
   value1 = np.random.uniform(size=(2, 3)).astype(np.float32)
   value2 = np.random.uniform(size=(2, 3)).astype(np.float32)
   value3 = np.random.uniform(size=(2, 3)).astype(np.float32)
   with self.test_session() as sess:
     out_tensor = Add(weights=[1, 2, 1])(
         tf.constant(value1), tf.constant(value2), tf.constant(value3))
     assert np.array_equal(value1 + 2 * value2 + value3, out_tensor.eval())
Ejemplo n.º 3
0
 def test_add(self):
   """Test that Add can be invoked."""
   value1 = np.random.uniform(size=(2, 3)).astype(np.float32)
   value2 = np.random.uniform(size=(2, 3)).astype(np.float32)
   value3 = np.random.uniform(size=(2, 3)).astype(np.float32)
   with self.session() as sess:
     out_tensor = Add(weights=[1, 2, 1])(tf.constant(value1),
                                         tf.constant(value2),
                                         tf.constant(value3))
     assert np.array_equal(value1 + 2 * value2 + value3, out_tensor.eval())