本文整理汇总了Python中object_detection.inputs._replace_empty_string_with_random_number方法的典型用法代码示例。如果您正苦于以下问题:Python inputs._replace_empty_string_with_random_number方法的具体用法?Python inputs._replace_empty_string_with_random_number怎么用?Python inputs._replace_empty_string_with_random_number使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类object_detection.inputs
的用法示例。
在下文中一共展示了inputs._replace_empty_string_with_random_number方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_output_is_integer_in_replace_empty_string_with_random_number
# 需要导入模块: from object_detection import inputs [as 别名]
# 或者: from object_detection.inputs import _replace_empty_string_with_random_number [as 别名]
def test_output_is_integer_in_replace_empty_string_with_random_number(self):
string_placeholder = tf.placeholder(tf.string, shape=[])
replaced_string = inputs._replace_empty_string_with_random_number(
string_placeholder)
empty_string = ''
feed_dict = {string_placeholder: empty_string}
tf.set_random_seed(0)
with self.test_session() as sess:
out_string = sess.run(replaced_string, feed_dict=feed_dict)
# Test whether out_string is a string which represents an integer.
int(out_string) # throws an error if out_string is not castable to int.
self.assertEqual(out_string, '2798129067578209328')
示例2: test_output_is_integer_in_replace_empty_string_with_random_number
# 需要导入模块: from object_detection import inputs [as 别名]
# 或者: from object_detection.inputs import _replace_empty_string_with_random_number [as 别名]
def test_output_is_integer_in_replace_empty_string_with_random_number(self):
string_placeholder = tf.placeholder(tf.string, shape=[])
replaced_string = inputs._replace_empty_string_with_random_number(
string_placeholder)
empty_string = ''
feed_dict = {string_placeholder: empty_string}
with self.test_session() as sess:
out_string = sess.run(replaced_string, feed_dict=feed_dict)
is_integer = True
try:
# Test whether out_string is a string which represents an integer, the
# casting below will throw an error if out_string is not castable to int.
int(out_string)
except ValueError:
is_integer = False
self.assertTrue(is_integer)
示例3: test_output_equal_in_replace_empty_string_with_random_number
# 需要导入模块: from object_detection import inputs [as 别名]
# 或者: from object_detection.inputs import _replace_empty_string_with_random_number [as 别名]
def test_output_equal_in_replace_empty_string_with_random_number(self):
string_placeholder = tf.placeholder(tf.string, shape=[])
replaced_string = inputs._replace_empty_string_with_random_number(
string_placeholder)
test_string = 'hello world'
feed_dict = {string_placeholder: test_string}
with self.test_session() as sess:
out_string = sess.run(replaced_string, feed_dict=feed_dict)
self.assertEqual(test_string, out_string)
示例4: test_output_equal_in_replace_empty_string_with_random_number
# 需要导入模块: from object_detection import inputs [as 别名]
# 或者: from object_detection.inputs import _replace_empty_string_with_random_number [as 别名]
def test_output_equal_in_replace_empty_string_with_random_number(self):
string_placeholder = tf.placeholder(tf.string, shape=[])
replaced_string = inputs._replace_empty_string_with_random_number(
string_placeholder)
test_string = b'hello world'
feed_dict = {string_placeholder: test_string}
with self.test_session() as sess:
out_string = sess.run(replaced_string, feed_dict=feed_dict)
self.assertEqual(test_string, out_string)