def testShape(self): shape = [10, 5] gradients = tf.random_normal(shape) net = networks.Adam() state = net.initial_state_for_inputs(gradients) update, _ = net(gradients, state) self.assertEqual(update.get_shape().as_list(), shape)
def testNonTrainable(self): """Tests the network doesn't contain trainable variables.""" shape = [10, 5] gradients = tf.random_normal(shape) net = networks.Adam() state = net.initial_state_for_inputs(gradients) net(gradients, state) variables = nn.get_variables_in_module(net) self.assertEqual(len(variables), 0)
def testZeroLearningRate(self): """Tests network produces zero updates with learning rate equal to zero.""" shape = [10] gradients = tf.random_normal(shape) net = networks.Adam(learning_rate=0) state = net.initial_state_for_inputs(gradients) update, _ = net(gradients, state) with self.test_session() as sess: update_np = sess.run(update) self.assertAllEqual(update_np, np.zeros(shape))