Example #1
0
 def test_div(self):
     layer = core.Div(divisor=2.0)
     input_np = onp.array([[1, 2, 3], [4, 5, 6]], dtype=onp.float32)
     output_np = layer(input_np)
     # absltest doesn't have ndarray equalities.
     expected_output_np = input_np / 2.0
     self.assertAlmostEqual(0.0,
                            onp.sum((output_np - expected_output_np)**2),
                            delta=1e-6)
Example #2
0
 def test_div_shapes(self):
     layer = core.Div(divisor=2.0)
     input_shape = (3, 2)
     expected_shape = (3, 2)
     output_shape = base.check_shape_agreement(layer, input_shape)
     self.assertEqual(output_shape, expected_shape)
Example #3
0
 def test_serial_div_div(self):
     layer = cb.Serial(core.Div(divisor=2.0), core.Div(divisor=5.0))
     input_shape = (3, 2)
     expected_shape = (3, 2)
     output_shape = base.check_shape_agreement(layer, input_shape)
     self.assertEqual(output_shape, expected_shape)
Example #4
0
 def test_parallel_div_div(self):
     layer = cb.Parallel(core.Div(divisor=0.5), core.Div(divisor=3.0))
     input_shape = ((3, 2), (4, 7))
     expected_shape = ((3, 2), (4, 7))
     output_shape = base.check_shape_agreement(layer, input_shape)
     self.assertEqual(output_shape, expected_shape)
Example #5
0
 def test_serial_one_in_one_out(self):
     layer = cb.Serial(core.Div(divisor=2.0))
     input_shape = ((3, 2), (4, 7))
     expected_shape = ((3, 2), (4, 7))
     output_shape = base.check_shape_agreement(layer, input_shape)
     self.assertEqual(output_shape, expected_shape)