本文整理汇总了Python中object_detection.utils.shape_utils.assert_shape_equal方法的典型用法代码示例。如果您正苦于以下问题:Python shape_utils.assert_shape_equal方法的具体用法?Python shape_utils.assert_shape_equal怎么用?Python shape_utils.assert_shape_equal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类object_detection.utils.shape_utils
的用法示例。
在下文中一共展示了shape_utils.assert_shape_equal方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unequal_static_shape_raises_exception
# 需要导入模块: from object_detection.utils import shape_utils [as 别名]
# 或者: from object_detection.utils.shape_utils import assert_shape_equal [as 别名]
def test_unequal_static_shape_raises_exception(self):
shape_a = tf.constant(np.zeros([4, 2, 2, 1]))
shape_b = tf.constant(np.zeros([4, 2, 3, 1]))
with self.assertRaisesRegexp(
ValueError, 'Unequal shapes'):
shape_utils.assert_shape_equal(
shape_utils.combined_static_and_dynamic_shape(shape_a),
shape_utils.combined_static_and_dynamic_shape(shape_b))
示例2: test_equal_static_shape_succeeds
# 需要导入模块: from object_detection.utils import shape_utils [as 别名]
# 或者: from object_detection.utils.shape_utils import assert_shape_equal [as 别名]
def test_equal_static_shape_succeeds(self):
shape_a = tf.constant(np.zeros([4, 2, 2, 1]))
shape_b = tf.constant(np.zeros([4, 2, 2, 1]))
with self.test_session() as sess:
op = shape_utils.assert_shape_equal(
shape_utils.combined_static_and_dynamic_shape(shape_a),
shape_utils.combined_static_and_dynamic_shape(shape_b))
sess.run(op)
示例3: test_unequal_dynamic_shape_raises_tf_assert
# 需要导入模块: from object_detection.utils import shape_utils [as 别名]
# 或者: from object_detection.utils.shape_utils import assert_shape_equal [as 别名]
def test_unequal_dynamic_shape_raises_tf_assert(self):
tensor_a = tf.placeholder(tf.float32, shape=[1, None, None, 3])
tensor_b = tf.placeholder(tf.float32, shape=[1, None, None, 3])
op = shape_utils.assert_shape_equal(
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([1, 4, 4, 3])})
示例4: test_equal_dynamic_shape_succeeds
# 需要导入模块: from object_detection.utils import shape_utils [as 别名]
# 或者: from object_detection.utils.shape_utils import assert_shape_equal [as 别名]
def test_equal_dynamic_shape_succeeds(self):
tensor_a = tf.placeholder(tf.float32, shape=[1, None, None, 3])
tensor_b = tf.placeholder(tf.float32, shape=[1, None, None, 3])
op = shape_utils.assert_shape_equal(
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([1, 2, 2, 3]),
tensor_b: np.zeros([1, 2, 2, 3])})