Python object_detection.utils.shape_utils.assert_shape_equal_along_first_dimension() Examples

The following are 30 code examples of object_detection.utils.shape_utils.assert_shape_equal_along_first_dimension(). 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.shape_utils , or try the search function .
Example #1
Source File: shape_utils_test.py    From open-solution-googleai-object-detection with MIT License 5 votes vote down vote up
def test_equal_static_shape_along_first_dim_succeeds(self):
    shape_a = tf.constant(np.zeros([4, 2, 2, 1]))
    shape_b = tf.constant(np.zeros([4, 7, 2]))
    with self.test_session() as sess:
      op = shape_utils.assert_shape_equal_along_first_dimension(
          shape_utils.combined_static_and_dynamic_shape(shape_a),
          shape_utils.combined_static_and_dynamic_shape(shape_b))
      sess.run(op) 
Example #2
Source File: shape_utils_test.py    From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 5 votes vote down vote up
def test_equal_dynamic_shape_along_first_dim_succeeds(self):
    tensor_a = tf.placeholder(tf.float32, shape=[None, None, None, 3])
    tensor_b = tf.placeholder(tf.float32, shape=[None])
    op = shape_utils.assert_shape_equal_along_first_dimension(
        shape_utils.combined_static_and_dynamic_shape(tensor_a),
        shape_utils.combined_static_and_dynamic_shape(tensor_b))
    with self.test_session() as sess:
      sess.run(op, feed_dict={tensor_a: np.zeros([5, 2, 2, 3]),
                              tensor_b: np.zeros([5])}) 
Example #3
Source File: shape_utils_test.py    From Elphas with Apache License 2.0 5 votes vote down vote up
def test_unequal_static_shape_along_first_dim_raises_exception(self):
    shape_a = tf.constant(np.zeros([4, 2, 2, 1]))
    shape_b = tf.constant(np.zeros([6, 2, 3, 1]))
    with self.assertRaisesRegexp(
        ValueError, 'Unequal first dimension'):
      shape_utils.assert_shape_equal_along_first_dimension(
          shape_utils.combined_static_and_dynamic_shape(shape_a),
          shape_utils.combined_static_and_dynamic_shape(shape_b)) 
Example #4
Source File: shape_utils_test.py    From Elphas with Apache License 2.0 5 votes vote down vote up
def test_equal_static_shape_along_first_dim_succeeds(self):
    shape_a = tf.constant(np.zeros([4, 2, 2, 1]))
    shape_b = tf.constant(np.zeros([4, 7, 2]))
    with self.test_session() as sess:
      op = shape_utils.assert_shape_equal_along_first_dimension(
          shape_utils.combined_static_and_dynamic_shape(shape_a),
          shape_utils.combined_static_and_dynamic_shape(shape_b))
      sess.run(op) 
Example #5
Source File: shape_utils_test.py    From Elphas with Apache License 2.0 5 votes vote down vote up
def test_unequal_dynamic_shape_along_first_dim_raises_tf_assert(self):
    tensor_a = tf.placeholder(tf.float32, shape=[None, None, None, 3])
    tensor_b = tf.placeholder(tf.float32, shape=[None, None, 3])
    op = shape_utils.assert_shape_equal_along_first_dimension(
        shape_utils.combined_static_and_dynamic_shape(tensor_a),
        shape_utils.combined_static_and_dynamic_shape(tensor_b))
    with self.test_session() as sess:
      with self.assertRaises(tf.errors.InvalidArgumentError):
        sess.run(op, feed_dict={tensor_a: np.zeros([1, 2, 2, 3]),
                                tensor_b: np.zeros([2, 4, 3])}) 
Example #6
Source File: shape_utils_test.py    From Elphas with Apache License 2.0 5 votes vote down vote up
def test_equal_dynamic_shape_along_first_dim_succeeds(self):
    tensor_a = tf.placeholder(tf.float32, shape=[None, None, None, 3])
    tensor_b = tf.placeholder(tf.float32, shape=[None])
    op = shape_utils.assert_shape_equal_along_first_dimension(
        shape_utils.combined_static_and_dynamic_shape(tensor_a),
        shape_utils.combined_static_and_dynamic_shape(tensor_b))
    with self.test_session() as sess:
      sess.run(op, feed_dict={tensor_a: np.zeros([5, 2, 2, 3]),
                              tensor_b: np.zeros([5])}) 
Example #7
Source File: shape_utils_test.py    From AniSeg with Apache License 2.0 5 votes vote down vote up
def test_unequal_static_shape_along_first_dim_raises_exception(self):
    shape_a = tf.constant(np.zeros([4, 2, 2, 1]))
    shape_b = tf.constant(np.zeros([6, 2, 3, 1]))
    with self.assertRaisesRegexp(
        ValueError, 'Unequal first dimension'):
      shape_utils.assert_shape_equal_along_first_dimension(
          shape_utils.combined_static_and_dynamic_shape(shape_a),
          shape_utils.combined_static_and_dynamic_shape(shape_b)) 
Example #8
Source File: shape_utils_test.py    From AniSeg with Apache License 2.0 5 votes vote down vote up
def test_equal_static_shape_along_first_dim_succeeds(self):
    shape_a = tf.constant(np.zeros([4, 2, 2, 1]))
    shape_b = tf.constant(np.zeros([4, 7, 2]))
    with self.test_session() as sess:
      op = shape_utils.assert_shape_equal_along_first_dimension(
          shape_utils.combined_static_and_dynamic_shape(shape_a),
          shape_utils.combined_static_and_dynamic_shape(shape_b))
      sess.run(op) 
Example #9
Source File: shape_utils_test.py    From AniSeg with Apache License 2.0 5 votes vote down vote up
def test_unequal_dynamic_shape_along_first_dim_raises_tf_assert(self):
    tensor_a = tf.placeholder(tf.float32, shape=[None, None, None, 3])
    tensor_b = tf.placeholder(tf.float32, shape=[None, None, 3])
    op = shape_utils.assert_shape_equal_along_first_dimension(
        shape_utils.combined_static_and_dynamic_shape(tensor_a),
        shape_utils.combined_static_and_dynamic_shape(tensor_b))
    with self.test_session() as sess:
      with self.assertRaises(tf.errors.InvalidArgumentError):
        sess.run(op, feed_dict={tensor_a: np.zeros([1, 2, 2, 3]),
                                tensor_b: np.zeros([2, 4, 3])}) 
Example #10
Source File: shape_utils_test.py    From AniSeg with Apache License 2.0 5 votes vote down vote up
def test_equal_dynamic_shape_along_first_dim_succeeds(self):
    tensor_a = tf.placeholder(tf.float32, shape=[None, None, None, 3])
    tensor_b = tf.placeholder(tf.float32, shape=[None])
    op = shape_utils.assert_shape_equal_along_first_dimension(
        shape_utils.combined_static_and_dynamic_shape(tensor_a),
        shape_utils.combined_static_and_dynamic_shape(tensor_b))
    with self.test_session() as sess:
      sess.run(op, feed_dict={tensor_a: np.zeros([5, 2, 2, 3]),
                              tensor_b: np.zeros([5])}) 
Example #11
Source File: shape_utils_test.py    From MAX-Object-Detector with Apache License 2.0 5 votes vote down vote up
def test_unequal_static_shape_along_first_dim_raises_exception(self):
    shape_a = tf.constant(np.zeros([4, 2, 2, 1]))
    shape_b = tf.constant(np.zeros([6, 2, 3, 1]))
    with self.assertRaisesRegexp(
        ValueError, 'Unequal first dimension'):
      shape_utils.assert_shape_equal_along_first_dimension(
          shape_utils.combined_static_and_dynamic_shape(shape_a),
          shape_utils.combined_static_and_dynamic_shape(shape_b)) 
Example #12
Source File: shape_utils_test.py    From MAX-Object-Detector with Apache License 2.0 5 votes vote down vote up
def test_equal_static_shape_along_first_dim_succeeds(self):
    shape_a = tf.constant(np.zeros([4, 2, 2, 1]))
    shape_b = tf.constant(np.zeros([4, 7, 2]))
    with self.test_session() as sess:
      op = shape_utils.assert_shape_equal_along_first_dimension(
          shape_utils.combined_static_and_dynamic_shape(shape_a),
          shape_utils.combined_static_and_dynamic_shape(shape_b))
      sess.run(op) 
Example #13
Source File: shape_utils_test.py    From MAX-Object-Detector with Apache License 2.0 5 votes vote down vote up
def test_unequal_dynamic_shape_along_first_dim_raises_tf_assert(self):
    tensor_a = tf.placeholder(tf.float32, shape=[None, None, None, 3])
    tensor_b = tf.placeholder(tf.float32, shape=[None, None, 3])
    op = shape_utils.assert_shape_equal_along_first_dimension(
        shape_utils.combined_static_and_dynamic_shape(tensor_a),
        shape_utils.combined_static_and_dynamic_shape(tensor_b))
    with self.test_session() as sess:
      with self.assertRaises(tf.errors.InvalidArgumentError):
        sess.run(op, feed_dict={tensor_a: np.zeros([1, 2, 2, 3]),
                                tensor_b: np.zeros([2, 4, 3])}) 
Example #14
Source File: shape_utils_test.py    From MAX-Object-Detector with Apache License 2.0 5 votes vote down vote up
def test_equal_dynamic_shape_along_first_dim_succeeds(self):
    tensor_a = tf.placeholder(tf.float32, shape=[None, None, None, 3])
    tensor_b = tf.placeholder(tf.float32, shape=[None])
    op = shape_utils.assert_shape_equal_along_first_dimension(
        shape_utils.combined_static_and_dynamic_shape(tensor_a),
        shape_utils.combined_static_and_dynamic_shape(tensor_b))
    with self.test_session() as sess:
      sess.run(op, feed_dict={tensor_a: np.zeros([5, 2, 2, 3]),
                              tensor_b: np.zeros([5])}) 
Example #15
Source File: shape_utils_test.py    From open-solution-googleai-object-detection with MIT License 5 votes vote down vote up
def test_unequal_static_shape_along_first_dim_raises_exception(self):
    shape_a = tf.constant(np.zeros([4, 2, 2, 1]))
    shape_b = tf.constant(np.zeros([6, 2, 3, 1]))
    with self.assertRaisesRegex(
        ValueError, 'Unequal first dimension'):
      shape_utils.assert_shape_equal_along_first_dimension(
          shape_utils.combined_static_and_dynamic_shape(shape_a),
          shape_utils.combined_static_and_dynamic_shape(shape_b)) 
Example #16
Source File: shape_utils_test.py    From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 5 votes vote down vote up
def test_unequal_dynamic_shape_along_first_dim_raises_tf_assert(self):
    tensor_a = tf.placeholder(tf.float32, shape=[None, None, None, 3])
    tensor_b = tf.placeholder(tf.float32, shape=[None, None, 3])
    op = shape_utils.assert_shape_equal_along_first_dimension(
        shape_utils.combined_static_and_dynamic_shape(tensor_a),
        shape_utils.combined_static_and_dynamic_shape(tensor_b))
    with self.test_session() as sess:
      with self.assertRaises(tf.errors.InvalidArgumentError):
        sess.run(op, feed_dict={tensor_a: np.zeros([1, 2, 2, 3]),
                                tensor_b: np.zeros([2, 4, 3])}) 
Example #17
Source File: shape_utils_test.py    From open-solution-googleai-object-detection with MIT License 5 votes vote down vote up
def test_unequal_dynamic_shape_along_first_dim_raises_tf_assert(self):
    tensor_a = tf.placeholder(tf.float32, shape=[None, None, None, 3])
    tensor_b = tf.placeholder(tf.float32, shape=[None, None, 3])
    op = shape_utils.assert_shape_equal_along_first_dimension(
        shape_utils.combined_static_and_dynamic_shape(tensor_a),
        shape_utils.combined_static_and_dynamic_shape(tensor_b))
    with self.test_session() as sess:
      with self.assertRaises(tf.errors.InvalidArgumentError):
        sess.run(op, feed_dict={tensor_a: np.zeros([1, 2, 2, 3]),
                                tensor_b: np.zeros([2, 4, 3])}) 
Example #18
Source File: shape_utils_test.py    From open-solution-googleai-object-detection with MIT License 5 votes vote down vote up
def test_equal_dynamic_shape_along_first_dim_succeeds(self):
    tensor_a = tf.placeholder(tf.float32, shape=[None, None, None, 3])
    tensor_b = tf.placeholder(tf.float32, shape=[None])
    op = shape_utils.assert_shape_equal_along_first_dimension(
        shape_utils.combined_static_and_dynamic_shape(tensor_a),
        shape_utils.combined_static_and_dynamic_shape(tensor_b))
    with self.test_session() as sess:
      sess.run(op, feed_dict={tensor_a: np.zeros([5, 2, 2, 3]),
                              tensor_b: np.zeros([5])}) 
Example #19
Source File: shape_utils_test.py    From g-tensorflow-models with Apache License 2.0 5 votes vote down vote up
def test_unequal_static_shape_along_first_dim_raises_exception(self):
    shape_a = tf.constant(np.zeros([4, 2, 2, 1]))
    shape_b = tf.constant(np.zeros([6, 2, 3, 1]))
    with self.assertRaisesRegexp(
        ValueError, 'Unequal first dimension'):
      shape_utils.assert_shape_equal_along_first_dimension(
          shape_utils.combined_static_and_dynamic_shape(shape_a),
          shape_utils.combined_static_and_dynamic_shape(shape_b)) 
Example #20
Source File: shape_utils_test.py    From g-tensorflow-models with Apache License 2.0 5 votes vote down vote up
def test_equal_static_shape_along_first_dim_succeeds(self):
    shape_a = tf.constant(np.zeros([4, 2, 2, 1]))
    shape_b = tf.constant(np.zeros([4, 7, 2]))
    with self.test_session() as sess:
      op = shape_utils.assert_shape_equal_along_first_dimension(
          shape_utils.combined_static_and_dynamic_shape(shape_a),
          shape_utils.combined_static_and_dynamic_shape(shape_b))
      sess.run(op) 
Example #21
Source File: shape_utils_test.py    From g-tensorflow-models with Apache License 2.0 5 votes vote down vote up
def test_unequal_dynamic_shape_along_first_dim_raises_tf_assert(self):
    tensor_a = tf.placeholder(tf.float32, shape=[None, None, None, 3])
    tensor_b = tf.placeholder(tf.float32, shape=[None, None, 3])
    op = shape_utils.assert_shape_equal_along_first_dimension(
        shape_utils.combined_static_and_dynamic_shape(tensor_a),
        shape_utils.combined_static_and_dynamic_shape(tensor_b))
    with self.test_session() as sess:
      with self.assertRaises(tf.errors.InvalidArgumentError):
        sess.run(op, feed_dict={tensor_a: np.zeros([1, 2, 2, 3]),
                                tensor_b: np.zeros([2, 4, 3])}) 
Example #22
Source File: shape_utils_test.py    From g-tensorflow-models with Apache License 2.0 5 votes vote down vote up
def test_equal_dynamic_shape_along_first_dim_succeeds(self):
    tensor_a = tf.placeholder(tf.float32, shape=[None, None, None, 3])
    tensor_b = tf.placeholder(tf.float32, shape=[None])
    op = shape_utils.assert_shape_equal_along_first_dimension(
        shape_utils.combined_static_and_dynamic_shape(tensor_a),
        shape_utils.combined_static_and_dynamic_shape(tensor_b))
    with self.test_session() as sess:
      sess.run(op, feed_dict={tensor_a: np.zeros([5, 2, 2, 3]),
                              tensor_b: np.zeros([5])}) 
Example #23
Source File: shape_utils_test.py    From models with Apache License 2.0 5 votes vote down vote up
def test_unequal_static_shape_along_first_dim_raises_exception(self):
    shape_a = tf.constant(np.zeros([4, 2, 2, 1]))
    shape_b = tf.constant(np.zeros([6, 2, 3, 1]))

    self.assertRaisesRegexp(
        ValueError, 'Unequal first dimension',
        shape_utils.assert_shape_equal_along_first_dimension,
        shape_utils.combined_static_and_dynamic_shape(shape_a),
        shape_utils.combined_static_and_dynamic_shape(shape_b)
    ) 
Example #24
Source File: shape_utils_test.py    From models with Apache License 2.0 5 votes vote down vote up
def test_equal_static_shape_along_first_dim_succeeds(self):

    def graph_fn():
      shape_a = tf.constant(np.zeros([4, 2, 2, 1]))
      shape_b = tf.constant(np.zeros([4, 7, 2]))
      shape_utils.assert_shape_equal_along_first_dimension(
          shape_utils.combined_static_and_dynamic_shape(shape_a),
          shape_utils.combined_static_and_dynamic_shape(shape_b))
      return tf.constant(0)

    self.execute(graph_fn, []) 
Example #25
Source File: shape_utils_test.py    From models with Apache License 2.0 5 votes vote down vote up
def test_unequal_dynamic_shape_along_first_dim_raises_tf_assert(self):

    def graph_fn(tensor_a, tensor_b):
      shape_utils.assert_shape_equal_along_first_dimension(
          shape_utils.combined_static_and_dynamic_shape(tensor_a),
          shape_utils.combined_static_and_dynamic_shape(tensor_b))

      return tf.constant(0)

    self.assertRaises(ValueError,
                      self.execute, graph_fn,
                      [np.zeros([1, 2, 2, 3]), np.zeros([2, 4, 3])]) 
Example #26
Source File: shape_utils_test.py    From models with Apache License 2.0 5 votes vote down vote up
def test_equal_dynamic_shape_along_first_dim_succeeds(self):

    def graph_fn(tensor_a, tensor_b):
      shape_utils.assert_shape_equal_along_first_dimension(
          shape_utils.combined_static_and_dynamic_shape(tensor_a),
          shape_utils.combined_static_and_dynamic_shape(tensor_b))
      return tf.constant(0)

    self.execute(graph_fn, [np.zeros([5, 2, 2, 3]), np.zeros([5])]) 
Example #27
Source File: shape_utils_test.py    From multilabel-image-classification-tensorflow with MIT License 5 votes vote down vote up
def test_unequal_static_shape_along_first_dim_raises_exception(self):
    shape_a = tf.constant(np.zeros([4, 2, 2, 1]))
    shape_b = tf.constant(np.zeros([6, 2, 3, 1]))
    with self.assertRaisesRegexp(
        ValueError, 'Unequal first dimension'):
      shape_utils.assert_shape_equal_along_first_dimension(
          shape_utils.combined_static_and_dynamic_shape(shape_a),
          shape_utils.combined_static_and_dynamic_shape(shape_b)) 
Example #28
Source File: shape_utils_test.py    From multilabel-image-classification-tensorflow with MIT License 5 votes vote down vote up
def test_equal_static_shape_along_first_dim_succeeds(self):
    shape_a = tf.constant(np.zeros([4, 2, 2, 1]))
    shape_b = tf.constant(np.zeros([4, 7, 2]))
    with self.test_session() as sess:
      op = shape_utils.assert_shape_equal_along_first_dimension(
          shape_utils.combined_static_and_dynamic_shape(shape_a),
          shape_utils.combined_static_and_dynamic_shape(shape_b))
      sess.run(op) 
Example #29
Source File: shape_utils_test.py    From multilabel-image-classification-tensorflow with MIT License 5 votes vote down vote up
def test_unequal_dynamic_shape_along_first_dim_raises_tf_assert(self):
    tensor_a = tf.placeholder(tf.float32, shape=[None, None, None, 3])
    tensor_b = tf.placeholder(tf.float32, shape=[None, None, 3])
    op = shape_utils.assert_shape_equal_along_first_dimension(
        shape_utils.combined_static_and_dynamic_shape(tensor_a),
        shape_utils.combined_static_and_dynamic_shape(tensor_b))
    with self.test_session() as sess:
      with self.assertRaises(tf.errors.InvalidArgumentError):
        sess.run(op, feed_dict={tensor_a: np.zeros([1, 2, 2, 3]),
                                tensor_b: np.zeros([2, 4, 3])}) 
Example #30
Source File: shape_utils_test.py    From multilabel-image-classification-tensorflow with MIT License 5 votes vote down vote up
def test_equal_dynamic_shape_along_first_dim_succeeds(self):
    tensor_a = tf.placeholder(tf.float32, shape=[None, None, None, 3])
    tensor_b = tf.placeholder(tf.float32, shape=[None])
    op = shape_utils.assert_shape_equal_along_first_dimension(
        shape_utils.combined_static_and_dynamic_shape(tensor_a),
        shape_utils.combined_static_and_dynamic_shape(tensor_b))
    with self.test_session() as sess:
      sess.run(op, feed_dict={tensor_a: np.zeros([5, 2, 2, 3]),
                              tensor_b: np.zeros([5])})