def test_gather_beams(self):
        x = tf.reshape(tf.range(24), [2, 3, 4])
        # x looks like:  [[[ 0  1  2  3]
        #                  [ 4  5  6  7]
        #                  [ 8  9 10 11]]
        #
        #                 [[12 13 14 15]
        #                  [16 17 18 19]
        #                  [20 21 22 23]]]

        y = beam_search._gather_beams(x, [[1, 2], [0, 2]], 2, 2)
        with self.session() as sess:
            y = sess.run(y)

        self.assertAllEqual([[[4, 5, 6, 7], [8, 9, 10, 11]],
                             [[12, 13, 14, 15], [20, 21, 22, 23]]], y)
Пример #2
0
  def test_gather_beams(self):
    x = tf.reshape(tf.range(24), [2, 3, 4])
    # x looks like:  [[[ 0  1  2  3]
    #                  [ 4  5  6  7]
    #                  [ 8  9 10 11]]
    #
    #                 [[12 13 14 15]
    #                  [16 17 18 19]
    #                  [20 21 22 23]]]

    y = beam_search._gather_beams(x, [[1, 2], [0, 2]], 2, 2)
    with self.test_session() as sess:
      y = sess.run(y)

    self.assertAllEqual([[[4, 5, 6, 7],
                          [8, 9, 10, 11]],
                         [[12, 13, 14, 15],
                          [20, 21, 22, 23]]],
                        y)