Ejemplo n.º 1
0
 def testRNMTPlusEncoder(self):
     sequence_length = [4, 6, 5]
     inputs = tf.zeros([3, 6, 5])
     encoder = encoders.RNMTPlusEncoder(6, 10)
     outputs, state, _ = encoder(inputs, sequence_length=sequence_length)
     self.assertEqual(6, len(state))
     self.assertEqual(10 * 2, tf.nest.flatten(state)[0].shape[-1])
     outputs = self.evaluate(outputs)
     self.assertAllEqual([3, max(sequence_length), 10], outputs.shape)
Ejemplo n.º 2
0
 def testRNMTPlusEncoder(self):
     sequence_length = [4, 6, 5]
     inputs = _build_dummy_sequences(sequence_length)
     encoder = encoders.RNMTPlusEncoder(6, 10)
     outputs, state, _ = encoder.encode(inputs,
                                        sequence_length=sequence_length)
     self.assertEqual(6, len(state))
     for s in state:
         self.assertIsInstance(s, tf.nn.rnn_cell.LSTMStateTuple)
     self.assertEqual(10 * 2, state[0].h.get_shape().as_list()[-1])
     with self.test_session() as sess:
         sess.run(tf.global_variables_initializer())
         outputs = sess.run(outputs)
         self.assertAllEqual([3, max(sequence_length), 10], outputs.shape)