Esempio n. 1
0
  def test_custom_call_kwargs_and_build(self):
    first_input_shape = (2, 3)
    second_input_shape = (2, 5)

    model = model_util.CustomCallModel()
    self.assertFalse(model.built, 'Model should not have been built')
    self.assertFalse(model.weights, ('Model should have no weights since it '
                                     'has not been built.'))
    with self.assertRaisesRegexp(
        ValueError, 'cannot build your model if it has positional'):
      model.build(input_shape=[first_input_shape, second_input_shape])
Esempio n. 2
0
 def test_no_inputs_in_signature(self):
   model = model_util.CustomCallModel()
   first = array_ops.ones([2, 3])
   second = array_ops.ones([2, 5])
   output = model(first, second)
   self.evaluate([v.initializer for v in model.variables])
   expected_output = self.evaluate(model.dense1(first) + model.dense2(second))
   self.assertAllClose(expected_output, self.evaluate(output))
   output = model(first, second, fiddle_with_output='yes')
   self.assertAllClose(10. * expected_output, self.evaluate(output))
   output = model(first, second=second, training=False)
   self.assertAllClose(expected_output, self.evaluate(output))