f7c759ca562303127a9991574d5a985d4dff99e8,sonnet/python/modules/gated_rnn_test.py,LSTMTest,testHiddenClipping,#LSTMTest#,667
Before Change
def testHiddenClipping(self):
core = snt.LSTM(hidden_size=5, hidden_clip_value=1.0)
obs = tf.constant(np.random.rand(3, 10), dtype=tf.float32)
hidden = tf.placeholder(tf.float32, shape=[3, 5])
cell = tf.placeholder(tf.float32, shape=[3, 5])
output = core(obs, [hidden, cell])
with self.test_session() as sess:
sess.run(tf.global_variables_initializer())
unclipped = np.random.rand(3, 5) - 0.5
unclipped *= 2.0 / unclipped.max()
clipped = unclipped.clip(-1., 1.)
output1, (hidden1, cell1) = sess.run(output, feed_dict={hidden: unclipped,
cell: unclipped})
output2, (hidden2, cell2) = sess.run(output, feed_dict={hidden: clipped,
cell: unclipped})
self.assertAllClose(output1, output2)
self.assertAllClose(hidden1, hidden2)
self.assertAllClose(cell1, cell2)
def testCellClipping(self):
core = snt.LSTM(hidden_size=5, cell_clip_value=1.0)
obs = tf.constant(np.random.rand(3, 10), dtype=tf.float32)
hidden = tf.placeholder(tf.float32, shape=[3, 5])
After Change
unclipped = unclipped.astype(np.float32)
clipped = unclipped.clip(-1., 1.)
hidden = tf.constant(unclipped)
cell = tf.constant(unclipped)
output = core(obs, [hidden, cell])
self.evaluate(tf.global_variables_initializer())
output1, (hidden1, cell1) = self.evaluate(output)
hidden = tf.constant(clipped)
output = core(obs, [hidden, cell])
output2, (hidden2, cell2) = self.evaluate(output)
self.assertAllClose(output1, output2)
In pattern: SUPERPATTERN
Frequency: 4
Non-data size: 19
Instances
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: testHiddenClipping
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
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: testHiddenClipping
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: testCellClipping
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