5568c56bd0e69841c0df940844251037cb6385cf,sonnet/python/modules/base_test.py,ModuleTest,testSharing,#ModuleTest#,473

Before Change


  def testSharing(self):
    batch_size = 3
    in_size = 4
    inputs1 = tf.placeholder(tf.float32, shape=[batch_size, in_size])
    inputs2 = tf.placeholder(tf.float32, shape=[batch_size, in_size])

    build = functools.partial(_make_model_with_params, output_size=10)
    model = base.Module(build)
    self.assertEqual(model.scope_name, "make_model_with_params")
    outputs1 = model(inputs1)
    outputs2 = model(inputs2)
    input_data = np.random.rand(batch_size, in_size)

    with self.test_session() as sess:
      sess.run(tf.global_variables_initializer())
      outputs1, outputs2 = sess.run(
          [outputs1, outputs2],
          feed_dict={inputs1: input_data,
                     inputs2: input_data})
      self.assertAllClose(outputs1, outputs2)

  def testCustomGetter(self):
    def simple_module_build(inputs):
      w = tf.get_variable("w", dtype=tf.float32, shape=[10, 10])
      b = tf.get_variable("b", dtype=tf.float32, shape=[10, 10])

After Change


    batch_size = 3
    in_size = 4
    input_data = np.random.rand(batch_size, in_size)
    inputs1 = tf.constant(input_data)
    inputs2 = tf.constant(input_data)

    build = functools.partial(_make_model_with_params, output_size=10)
    model = base.Module(build)
    self.assertEqual(model.scope_name, "make_model_with_params")
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 16

Instances


Project Name: deepmind/sonnet
Commit Name: 5568c56bd0e69841c0df940844251037cb6385cf
Time: 2018-07-17
Author: tomhennigan@google.com
File Name: sonnet/python/modules/base_test.py
Class Name: ModuleTest
Method Name: testSharing


Project Name: deepmind/sonnet
Commit Name: 5568c56bd0e69841c0df940844251037cb6385cf
Time: 2018-07-17
Author: tomhennigan@google.com
File Name: sonnet/python/modules/base_test.py
Class Name: ModuleTest
Method Name: testSharing


Project Name: deepmind/sonnet
Commit Name: f7c759ca562303127a9991574d5a985d4dff99e8
Time: 2018-07-17
Author: tomhennigan@google.com
File Name: sonnet/python/modules/gated_rnn_test.py
Class Name: LSTMTest
Method Name: testPeephole


Project Name: deepmind/sonnet
Commit Name: f7c759ca562303127a9991574d5a985d4dff99e8
Time: 2018-07-17
Author: tomhennigan@google.com
File Name: sonnet/python/modules/gated_rnn_test.py
Class Name: LSTMTest
Method Name: testComputation