def testMultiplyReducerWithSequenceAndMaxTime(self): a = [[[1], [-1], [-1]], [[1], [2], [3]], [[1], [2], [-1]]] b = [ [[1], [2], [3], [4], [-1]], [[1], [2], [-1], [-1], [-1]], [[1], [2], [-1], [-1], [-1]], ] expected = [ [[1], [2], [3], [4], [0]], [[1], [4], [3], [0], [0]], [[1], [4], [0], [0], [0]], ] length_a = [1, 3, 2] length_b = [4, 2, 2] reduced, length = reducer.MultiplyReducer()( [ tf.constant(a, dtype=tf.float32), tf.constant(b, dtype=tf.float32) ], [tf.constant(length_a), tf.constant(length_b)], ) reduced, length = self.evaluate([reduced, length]) self.assertAllEqual(expected, reduced) self.assertAllEqual([4, 3, 2], length)
def testMultiplyReducerWithSequence(self): a = [[[1], [-1], [-1]], [[1], [2], [3]], [[1], [2], [-1]]] b = [[[1], [2], [3], [4]], [[1], [2], [-1], [-1]], [[1], [2], [-1], [-1]]] expected = [[[1], [2], [3], [4]], [[1], [4], [3], [0]], [[1], [4], [0], [0]]] length_a = [1, 3, 2] length_b = [4, 2, 2] reduced, length = reducer.MultiplyReducer().reduce_sequence([ tf.constant(a, dtype=tf.float32), tf.constant(b, dtype=tf.float32) ], [tf.constant(length_a), tf.constant(length_b)]) with self.test_session() as sess: reduced, length = sess.run([reduced, length]) self.assertAllEqual(expected, reduced) self.assertAllEqual([4, 3, 2], length)