def test_lstm(self): """Test that LSTM can be invoked.""" batch_size = 10 n_hidden = 7 in_channels = 4 n_repeat = 2 n_steps = 6 in_tensor = np.random.rand(batch_size, n_steps, in_channels) with self.session() as sess: in_tensor = tf.convert_to_tensor(in_tensor, dtype=tf.float32) out_tensor = LSTM(n_hidden, batch_size)(in_tensor) sess.run(tf.global_variables_initializer()) out_tensor = out_tensor.eval() assert out_tensor.shape == (batch_size, n_steps, n_hidden)
def test_LSTM_pickle(): tg = TensorGraph() feature = Feature(shape=(tg.batch_size, 10, 10)) layer = LSTM(n_hidden=10, batch_size=tg.batch_size, in_layers=feature) tg.add_output(layer) tg.set_loss(layer) tg.build() tg.save()