Python object_detection.utils.ops.matmul_gather_on_zeroth_axis() Examples

The following are 30 code examples of object_detection.utils.ops.matmul_gather_on_zeroth_axis(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module object_detection.utils.ops , or try the search function .
Example #1
Source File: ops_test.py    From MAX-Object-Detector with Apache License 2.0 5 votes vote down vote up
def test_gather_with_dynamic_shape_input(self):
    params_placeholder = tf.placeholder(tf.float32, shape=[None, 4])
    indices_placeholder = tf.placeholder(tf.int32, shape=[None])
    gather_result = ops.matmul_gather_on_zeroth_axis(
        params_placeholder, indices_placeholder)
    params = np.array([[1, 2, 3, 4],
                       [5, 6, 7, 8],
                       [9, 10, 11, 12],
                       [0, 1, 0, 0]], dtype=np.float32)
    indices = np.array([0, 0, 0, 0, 0, 0])
    expected_output = np.array(6*[[1, 2, 3, 4]])
    with self.test_session() as sess:
      gather_output = sess.run(gather_result, feed_dict={
          params_placeholder: params, indices_placeholder: indices})
      self.assertAllClose(gather_output, expected_output) 
Example #2
Source File: ops_test.py    From g-tensorflow-models with Apache License 2.0 5 votes vote down vote up
def test_gather_with_dynamic_shape_input(self):
    params_placeholder = tf.placeholder(tf.float32, shape=[None, 4])
    indices_placeholder = tf.placeholder(tf.int32, shape=[None])
    gather_result = ops.matmul_gather_on_zeroth_axis(
        params_placeholder, indices_placeholder)
    params = np.array([[1, 2, 3, 4],
                       [5, 6, 7, 8],
                       [9, 10, 11, 12],
                       [0, 1, 0, 0]], dtype=np.float32)
    indices = np.array([0, 0, 0, 0, 0, 0])
    expected_output = np.array(6*[[1, 2, 3, 4]])
    with self.test_session() as sess:
      gather_output = sess.run(gather_result, feed_dict={
          params_placeholder: params, indices_placeholder: indices})
      self.assertAllClose(gather_output, expected_output) 
Example #3
Source File: ops_test.py    From g-tensorflow-models with Apache License 2.0 5 votes vote down vote up
def test_gather_with_many_indices(self):

    def graph_fn(params, indices):
      return ops.matmul_gather_on_zeroth_axis(params, indices)

    params = np.array([[1, 2, 3, 4],
                       [5, 6, 7, 8],
                       [9, 10, 11, 12],
                       [0, 1, 0, 0]], dtype=np.float32)
    indices = np.array([0, 0, 0, 0, 0, 0], dtype=np.int32)
    expected_output = np.array(6*[[1, 2, 3, 4]])
    gather_output = self.execute(graph_fn, [params, indices])
    self.assertAllClose(gather_output, expected_output) 
Example #4
Source File: ops_test.py    From open-solution-googleai-object-detection with MIT License 5 votes vote down vote up
def test_gather_with_dynamic_shape_input(self):
    params_placeholder = tf.placeholder(tf.float32, shape=[None, 4])
    indices_placeholder = tf.placeholder(tf.int32, shape=[None])
    gather_result = ops.matmul_gather_on_zeroth_axis(
        params_placeholder, indices_placeholder)
    params = np.array([[1, 2, 3, 4],
                       [5, 6, 7, 8],
                       [9, 10, 11, 12],
                       [0, 1, 0, 0]], dtype=np.float32)
    indices = np.array([0, 0, 0, 0, 0, 0])
    expected_output = np.array(6*[[1, 2, 3, 4]])
    with self.test_session() as sess:
      gather_output = sess.run(gather_result, feed_dict={
          params_placeholder: params, indices_placeholder: indices})
      self.assertAllClose(gather_output, expected_output) 
Example #5
Source File: ops_test.py    From open-solution-googleai-object-detection with MIT License 5 votes vote down vote up
def test_gather_with_many_indices(self):

    def graph_fn(params, indices):
      return ops.matmul_gather_on_zeroth_axis(params, indices)

    params = np.array([[1, 2, 3, 4],
                       [5, 6, 7, 8],
                       [9, 10, 11, 12],
                       [0, 1, 0, 0]], dtype=np.float32)
    indices = np.array([0, 0, 0, 0, 0, 0], dtype=np.int32)
    expected_output = np.array(6*[[1, 2, 3, 4]])
    gather_output = self.execute(graph_fn, [params, indices])
    self.assertAllClose(gather_output, expected_output) 
Example #6
Source File: ops_test.py    From open-solution-googleai-object-detection with MIT License 5 votes vote down vote up
def test_gather_3d(self):

    def graph_fn(params, indices):
      return ops.matmul_gather_on_zeroth_axis(params, indices)

    params = np.array([[[1, 2], [3, 4]],
                       [[5, 6], [7, 8]],
                       [[9, 10], [11, 12]],
                       [[0, 1], [0, 0]]], dtype=np.float32)
    indices = np.array([0, 3, 1], dtype=np.int32)
    expected_output = np.array([[[1, 2], [3, 4]],
                                [[0, 1], [0, 0]],
                                [[5, 6], [7, 8]]])
    gather_output = self.execute(graph_fn, [params, indices])
    self.assertAllClose(gather_output, expected_output) 
Example #7
Source File: ops_test.py    From g-tensorflow-models with Apache License 2.0 5 votes vote down vote up
def test_gather_2d(self):

    def graph_fn(params, indices):
      return ops.matmul_gather_on_zeroth_axis(params, indices)

    params = np.array([[1, 2, 3, 4],
                       [5, 6, 7, 8],
                       [9, 10, 11, 12],
                       [0, 1, 0, 0]], dtype=np.float32)
    indices = np.array([2, 2, 1], dtype=np.int32)
    expected_output = np.array([[9, 10, 11, 12], [9, 10, 11, 12], [5, 6, 7, 8]])
    gather_output = self.execute(graph_fn, [params, indices])
    self.assertAllClose(gather_output, expected_output) 
Example #8
Source File: ops_test.py    From models with Apache License 2.0 5 votes vote down vote up
def test_gather_3d(self):

    def graph_fn(params, indices):
      return ops.matmul_gather_on_zeroth_axis(params, indices)

    params = np.array([[[1, 2], [3, 4]],
                       [[5, 6], [7, 8]],
                       [[9, 10], [11, 12]],
                       [[0, 1], [0, 0]]], dtype=np.float32)
    indices = np.array([0, 3, 1], dtype=np.int32)
    expected_output = np.array([[[1, 2], [3, 4]],
                                [[0, 1], [0, 0]],
                                [[5, 6], [7, 8]]])
    gather_output = self.execute(graph_fn, [params, indices])
    self.assertAllClose(gather_output, expected_output) 
Example #9
Source File: ops_test.py    From models with Apache License 2.0 5 votes vote down vote up
def test_gather_with_many_indices(self):

    def graph_fn(params, indices):
      return ops.matmul_gather_on_zeroth_axis(params, indices)

    params = np.array([[1, 2, 3, 4],
                       [5, 6, 7, 8],
                       [9, 10, 11, 12],
                       [0, 1, 0, 0]], dtype=np.float32)
    indices = np.array([0, 0, 0, 0, 0, 0], dtype=np.int32)
    expected_output = np.array(6*[[1, 2, 3, 4]])
    gather_output = self.execute(graph_fn, [params, indices])
    self.assertAllClose(gather_output, expected_output) 
Example #10
Source File: ops_test.py    From models with Apache License 2.0 5 votes vote down vote up
def test_gather_with_dynamic_shape_input(self):

    def graph_fn(params, indices):
      return ops.matmul_gather_on_zeroth_axis(params, indices)

    params = np.array([[1, 2, 3, 4],
                       [5, 6, 7, 8],
                       [9, 10, 11, 12],
                       [0, 1, 0, 0]], dtype=np.float32)
    indices = np.array([0, 0, 0, 0, 0, 0])
    expected_output = np.array(6*[[1, 2, 3, 4]])
    gather_output = self.execute(graph_fn, [params, indices])
    self.assertAllClose(gather_output, expected_output) 
Example #11
Source File: ops_test.py    From multilabel-image-classification-tensorflow with MIT License 5 votes vote down vote up
def test_gather_2d(self):

    def graph_fn(params, indices):
      return ops.matmul_gather_on_zeroth_axis(params, indices)

    params = np.array([[1, 2, 3, 4],
                       [5, 6, 7, 8],
                       [9, 10, 11, 12],
                       [0, 1, 0, 0]], dtype=np.float32)
    indices = np.array([2, 2, 1], dtype=np.int32)
    expected_output = np.array([[9, 10, 11, 12], [9, 10, 11, 12], [5, 6, 7, 8]])
    gather_output = self.execute(graph_fn, [params, indices])
    self.assertAllClose(gather_output, expected_output) 
Example #12
Source File: ops_test.py    From multilabel-image-classification-tensorflow with MIT License 5 votes vote down vote up
def test_gather_3d(self):

    def graph_fn(params, indices):
      return ops.matmul_gather_on_zeroth_axis(params, indices)

    params = np.array([[[1, 2], [3, 4]],
                       [[5, 6], [7, 8]],
                       [[9, 10], [11, 12]],
                       [[0, 1], [0, 0]]], dtype=np.float32)
    indices = np.array([0, 3, 1], dtype=np.int32)
    expected_output = np.array([[[1, 2], [3, 4]],
                                [[0, 1], [0, 0]],
                                [[5, 6], [7, 8]]])
    gather_output = self.execute(graph_fn, [params, indices])
    self.assertAllClose(gather_output, expected_output) 
Example #13
Source File: ops_test.py    From multilabel-image-classification-tensorflow with MIT License 5 votes vote down vote up
def test_gather_with_many_indices(self):

    def graph_fn(params, indices):
      return ops.matmul_gather_on_zeroth_axis(params, indices)

    params = np.array([[1, 2, 3, 4],
                       [5, 6, 7, 8],
                       [9, 10, 11, 12],
                       [0, 1, 0, 0]], dtype=np.float32)
    indices = np.array([0, 0, 0, 0, 0, 0], dtype=np.int32)
    expected_output = np.array(6*[[1, 2, 3, 4]])
    gather_output = self.execute(graph_fn, [params, indices])
    self.assertAllClose(gather_output, expected_output) 
Example #14
Source File: ops_test.py    From multilabel-image-classification-tensorflow with MIT License 5 votes vote down vote up
def test_gather_with_dynamic_shape_input(self):
    params_placeholder = tf.placeholder(tf.float32, shape=[None, 4])
    indices_placeholder = tf.placeholder(tf.int32, shape=[None])
    gather_result = ops.matmul_gather_on_zeroth_axis(
        params_placeholder, indices_placeholder)
    params = np.array([[1, 2, 3, 4],
                       [5, 6, 7, 8],
                       [9, 10, 11, 12],
                       [0, 1, 0, 0]], dtype=np.float32)
    indices = np.array([0, 0, 0, 0, 0, 0])
    expected_output = np.array(6*[[1, 2, 3, 4]])
    with self.test_session() as sess:
      gather_output = sess.run(gather_result, feed_dict={
          params_placeholder: params, indices_placeholder: indices})
      self.assertAllClose(gather_output, expected_output) 
Example #15
Source File: ops_test.py    From models with Apache License 2.0 5 votes vote down vote up
def test_gather_2d(self):

    def graph_fn(params, indices):
      return ops.matmul_gather_on_zeroth_axis(params, indices)

    params = np.array([[1, 2, 3, 4],
                       [5, 6, 7, 8],
                       [9, 10, 11, 12],
                       [0, 1, 0, 0]], dtype=np.float32)
    indices = np.array([2, 2, 1], dtype=np.int32)
    expected_output = np.array([[9, 10, 11, 12], [9, 10, 11, 12], [5, 6, 7, 8]])
    gather_output = self.execute(graph_fn, [params, indices])
    self.assertAllClose(gather_output, expected_output) 
Example #16
Source File: ops_test.py    From open-solution-googleai-object-detection with MIT License 5 votes vote down vote up
def test_gather_2d(self):

    def graph_fn(params, indices):
      return ops.matmul_gather_on_zeroth_axis(params, indices)

    params = np.array([[1, 2, 3, 4],
                       [5, 6, 7, 8],
                       [9, 10, 11, 12],
                       [0, 1, 0, 0]], dtype=np.float32)
    indices = np.array([2, 2, 1], dtype=np.int32)
    expected_output = np.array([[9, 10, 11, 12], [9, 10, 11, 12], [5, 6, 7, 8]])
    gather_output = self.execute(graph_fn, [params, indices])
    self.assertAllClose(gather_output, expected_output) 
Example #17
Source File: ops_test.py    From MAX-Object-Detector with Apache License 2.0 5 votes vote down vote up
def test_gather_with_many_indices(self):

    def graph_fn(params, indices):
      return ops.matmul_gather_on_zeroth_axis(params, indices)

    params = np.array([[1, 2, 3, 4],
                       [5, 6, 7, 8],
                       [9, 10, 11, 12],
                       [0, 1, 0, 0]], dtype=np.float32)
    indices = np.array([0, 0, 0, 0, 0, 0], dtype=np.int32)
    expected_output = np.array(6*[[1, 2, 3, 4]])
    gather_output = self.execute(graph_fn, [params, indices])
    self.assertAllClose(gather_output, expected_output) 
Example #18
Source File: ops_test.py    From MAX-Object-Detector with Apache License 2.0 5 votes vote down vote up
def test_gather_3d(self):

    def graph_fn(params, indices):
      return ops.matmul_gather_on_zeroth_axis(params, indices)

    params = np.array([[[1, 2], [3, 4]],
                       [[5, 6], [7, 8]],
                       [[9, 10], [11, 12]],
                       [[0, 1], [0, 0]]], dtype=np.float32)
    indices = np.array([0, 3, 1], dtype=np.int32)
    expected_output = np.array([[[1, 2], [3, 4]],
                                [[0, 1], [0, 0]],
                                [[5, 6], [7, 8]]])
    gather_output = self.execute(graph_fn, [params, indices])
    self.assertAllClose(gather_output, expected_output) 
Example #19
Source File: ops_test.py    From MAX-Object-Detector with Apache License 2.0 5 votes vote down vote up
def test_gather_2d(self):

    def graph_fn(params, indices):
      return ops.matmul_gather_on_zeroth_axis(params, indices)

    params = np.array([[1, 2, 3, 4],
                       [5, 6, 7, 8],
                       [9, 10, 11, 12],
                       [0, 1, 0, 0]], dtype=np.float32)
    indices = np.array([2, 2, 1], dtype=np.int32)
    expected_output = np.array([[9, 10, 11, 12], [9, 10, 11, 12], [5, 6, 7, 8]])
    gather_output = self.execute(graph_fn, [params, indices])
    self.assertAllClose(gather_output, expected_output) 
Example #20
Source File: ops_test.py    From AniSeg with Apache License 2.0 5 votes vote down vote up
def test_gather_with_dynamic_shape_input(self):
    params_placeholder = tf.placeholder(tf.float32, shape=[None, 4])
    indices_placeholder = tf.placeholder(tf.int32, shape=[None])
    gather_result = ops.matmul_gather_on_zeroth_axis(
        params_placeholder, indices_placeholder)
    params = np.array([[1, 2, 3, 4],
                       [5, 6, 7, 8],
                       [9, 10, 11, 12],
                       [0, 1, 0, 0]], dtype=np.float32)
    indices = np.array([0, 0, 0, 0, 0, 0])
    expected_output = np.array(6*[[1, 2, 3, 4]])
    with self.test_session() as sess:
      gather_output = sess.run(gather_result, feed_dict={
          params_placeholder: params, indices_placeholder: indices})
      self.assertAllClose(gather_output, expected_output) 
Example #21
Source File: ops_test.py    From AniSeg with Apache License 2.0 5 votes vote down vote up
def test_gather_with_many_indices(self):

    def graph_fn(params, indices):
      return ops.matmul_gather_on_zeroth_axis(params, indices)

    params = np.array([[1, 2, 3, 4],
                       [5, 6, 7, 8],
                       [9, 10, 11, 12],
                       [0, 1, 0, 0]], dtype=np.float32)
    indices = np.array([0, 0, 0, 0, 0, 0], dtype=np.int32)
    expected_output = np.array(6*[[1, 2, 3, 4]])
    gather_output = self.execute(graph_fn, [params, indices])
    self.assertAllClose(gather_output, expected_output) 
Example #22
Source File: ops_test.py    From AniSeg with Apache License 2.0 5 votes vote down vote up
def test_gather_3d(self):

    def graph_fn(params, indices):
      return ops.matmul_gather_on_zeroth_axis(params, indices)

    params = np.array([[[1, 2], [3, 4]],
                       [[5, 6], [7, 8]],
                       [[9, 10], [11, 12]],
                       [[0, 1], [0, 0]]], dtype=np.float32)
    indices = np.array([0, 3, 1], dtype=np.int32)
    expected_output = np.array([[[1, 2], [3, 4]],
                                [[0, 1], [0, 0]],
                                [[5, 6], [7, 8]]])
    gather_output = self.execute(graph_fn, [params, indices])
    self.assertAllClose(gather_output, expected_output) 
Example #23
Source File: ops_test.py    From AniSeg with Apache License 2.0 5 votes vote down vote up
def test_gather_2d(self):

    def graph_fn(params, indices):
      return ops.matmul_gather_on_zeroth_axis(params, indices)

    params = np.array([[1, 2, 3, 4],
                       [5, 6, 7, 8],
                       [9, 10, 11, 12],
                       [0, 1, 0, 0]], dtype=np.float32)
    indices = np.array([2, 2, 1], dtype=np.int32)
    expected_output = np.array([[9, 10, 11, 12], [9, 10, 11, 12], [5, 6, 7, 8]])
    gather_output = self.execute(graph_fn, [params, indices])
    self.assertAllClose(gather_output, expected_output) 
Example #24
Source File: ops_test.py    From monopsr with MIT License 5 votes vote down vote up
def test_gather_with_dynamic_shape_input(self):
        params_placeholder = tf.placeholder(tf.float32, shape=[None, 4])
        indices_placeholder = tf.placeholder(tf.int32, shape=[None])
        gather_result = ops.matmul_gather_on_zeroth_axis(
            params_placeholder, indices_placeholder)
        params = np.array([[1, 2, 3, 4],
                           [5, 6, 7, 8],
                           [9, 10, 11, 12],
                           [0, 1, 0, 0]], dtype=np.float32)
        indices = np.array([0, 0, 0, 0, 0, 0])
        expected_output = np.array(6 * [[1, 2, 3, 4]])
        with self.test_session() as sess:
            gather_output = sess.run(gather_result, feed_dict={
                params_placeholder: params, indices_placeholder: indices})
            self.assertAllClose(gather_output, expected_output) 
Example #25
Source File: ops_test.py    From monopsr with MIT License 5 votes vote down vote up
def test_gather_with_many_indices(self):

        def graph_fn(params, indices):
            return ops.matmul_gather_on_zeroth_axis(params, indices)

        params = np.array([[1, 2, 3, 4],
                           [5, 6, 7, 8],
                           [9, 10, 11, 12],
                           [0, 1, 0, 0]], dtype=np.float32)
        indices = np.array([0, 0, 0, 0, 0, 0], dtype=np.int32)
        expected_output = np.array(6 * [[1, 2, 3, 4]])
        gather_output = self.execute(graph_fn, [params, indices])
        self.assertAllClose(gather_output, expected_output) 
Example #26
Source File: ops_test.py    From monopsr with MIT License 5 votes vote down vote up
def test_gather_3d(self):

        def graph_fn(params, indices):
            return ops.matmul_gather_on_zeroth_axis(params, indices)

        params = np.array([[[1, 2], [3, 4]],
                           [[5, 6], [7, 8]],
                           [[9, 10], [11, 12]],
                           [[0, 1], [0, 0]]], dtype=np.float32)
        indices = np.array([0, 3, 1], dtype=np.int32)
        expected_output = np.array([[[1, 2], [3, 4]],
                                    [[0, 1], [0, 0]],
                                    [[5, 6], [7, 8]]])
        gather_output = self.execute(graph_fn, [params, indices])
        self.assertAllClose(gather_output, expected_output) 
Example #27
Source File: ops_test.py    From monopsr with MIT License 5 votes vote down vote up
def test_gather_2d(self):

        def graph_fn(params, indices):
            return ops.matmul_gather_on_zeroth_axis(params, indices)

        params = np.array([[1, 2, 3, 4],
                           [5, 6, 7, 8],
                           [9, 10, 11, 12],
                           [0, 1, 0, 0]], dtype=np.float32)
        indices = np.array([2, 2, 1], dtype=np.int32)
        expected_output = np.array([[9, 10, 11, 12], [9, 10, 11, 12], [5, 6, 7, 8]])
        gather_output = self.execute(graph_fn, [params, indices])
        self.assertAllClose(gather_output, expected_output) 
Example #28
Source File: ops_test.py    From Elphas with Apache License 2.0 5 votes vote down vote up
def test_gather_with_dynamic_shape_input(self):
    params_placeholder = tf.placeholder(tf.float32, shape=[None, 4])
    indices_placeholder = tf.placeholder(tf.int32, shape=[None])
    gather_result = ops.matmul_gather_on_zeroth_axis(
        params_placeholder, indices_placeholder)
    params = np.array([[1, 2, 3, 4],
                       [5, 6, 7, 8],
                       [9, 10, 11, 12],
                       [0, 1, 0, 0]], dtype=np.float32)
    indices = np.array([0, 0, 0, 0, 0, 0])
    expected_output = np.array(6*[[1, 2, 3, 4]])
    with self.test_session() as sess:
      gather_output = sess.run(gather_result, feed_dict={
          params_placeholder: params, indices_placeholder: indices})
      self.assertAllClose(gather_output, expected_output) 
Example #29
Source File: ops_test.py    From Elphas with Apache License 2.0 5 votes vote down vote up
def test_gather_with_many_indices(self):

    def graph_fn(params, indices):
      return ops.matmul_gather_on_zeroth_axis(params, indices)

    params = np.array([[1, 2, 3, 4],
                       [5, 6, 7, 8],
                       [9, 10, 11, 12],
                       [0, 1, 0, 0]], dtype=np.float32)
    indices = np.array([0, 0, 0, 0, 0, 0])
    expected_output = np.array(6*[[1, 2, 3, 4]])
    gather_output = self.execute(graph_fn, [params, indices])
    self.assertAllClose(gather_output, expected_output) 
Example #30
Source File: ops_test.py    From Elphas with Apache License 2.0 5 votes vote down vote up
def test_gather_3d(self):

    def graph_fn(params, indices):
      return ops.matmul_gather_on_zeroth_axis(params, indices)

    params = np.array([[[1, 2], [3, 4]],
                       [[5, 6], [7, 8]],
                       [[9, 10], [11, 12]],
                       [[0, 1], [0, 0]]], dtype=np.float32)
    indices = np.array([0, 3, 1])
    expected_output = np.array([[[1, 2], [3, 4]],
                                [[0, 1], [0, 0]],
                                [[5, 6], [7, 8]]])
    gather_output = self.execute(graph_fn, [params, indices])
    self.assertAllClose(gather_output, expected_output)