本文整理汇总了Python中official.utils.misc.model_helpers.generate_synthetic_data方法的典型用法代码示例。如果您正苦于以下问题:Python model_helpers.generate_synthetic_data方法的具体用法?Python model_helpers.generate_synthetic_data怎么用?Python model_helpers.generate_synthetic_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类official.utils.misc.model_helpers
的用法示例。
在下文中一共展示了model_helpers.generate_synthetic_data方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_generate_nested_data
# 需要导入模块: from official.utils.misc import model_helpers [as 别名]
# 或者: from official.utils.misc.model_helpers import generate_synthetic_data [as 别名]
def test_generate_nested_data(self):
d = model_helpers.generate_synthetic_data(
input_shape={'a': tf.TensorShape([2]),
'b': {'c': tf.TensorShape([3]), 'd': tf.TensorShape([])}},
input_value=1.1)
element = d.make_one_shot_iterator().get_next()
self.assertIn('a', element)
self.assertIn('b', element)
self.assertEquals(len(element['b']), 2)
self.assertIn('c', element['b'])
self.assertIn('d', element['b'])
self.assertNotIn('c', element)
with self.test_session() as sess:
inp = sess.run(element)
self.assertAllClose(inp['a'], [1.1, 1.1])
self.assertAllClose(inp['b']['c'], [1.1, 1.1, 1.1])
self.assertAllClose(inp['b']['d'], 1.1)
示例2: test_generate_nested_data
# 需要导入模块: from official.utils.misc import model_helpers [as 别名]
# 或者: from official.utils.misc.model_helpers import generate_synthetic_data [as 别名]
def test_generate_nested_data(self):
d = model_helpers.generate_synthetic_data(
input_shape={'a': tf.TensorShape([2]),
'b': {'c': tf.TensorShape([3]), 'd': tf.TensorShape([])}},
input_value=1.1)
element = tf.compat.v1.data.make_one_shot_iterator(d).get_next()
self.assertIn('a', element)
self.assertIn('b', element)
self.assertEquals(len(element['b']), 2)
self.assertIn('c', element['b'])
self.assertIn('d', element['b'])
self.assertNotIn('c', element)
with self.session() as sess:
inp = sess.run(element)
self.assertAllClose(inp['a'], [1.1, 1.1])
self.assertAllClose(inp['b']['c'], [1.1, 1.1, 1.1])
self.assertAllClose(inp['b']['d'], 1.1)
开发者ID:ShivangShekhar,项目名称:Live-feed-object-device-identification-using-Tensorflow-and-OpenCV,代码行数:21,代码来源:model_helpers_test.py
示例3: _generate_synthetic_data
# 需要导入模块: from official.utils.misc import model_helpers [as 别名]
# 或者: from official.utils.misc.model_helpers import generate_synthetic_data [as 别名]
def _generate_synthetic_data(params):
"""Create synthetic data based on the parameter batch size."""
batch_size = int(params["batch_size"] // params["max_length"])
length = params["max_length"]
dataset = model_helpers.generate_synthetic_data(
input_shape=tf.TensorShape([length]),
input_value=1,
input_dtype=tf.int64,
label_shape=tf.TensorShape([length]),
label_value=1,
label_dtype=tf.int64,
)
if params["static_batch"]:
dataset = dataset.batch(batch_size, drop_remainder=True)
else:
dataset = dataset.padded_batch(batch_size, ([None], [None]))
return dataset
示例4: test_generate_synethetic_data
# 需要导入模块: from official.utils.misc import model_helpers [as 别名]
# 或者: from official.utils.misc.model_helpers import generate_synthetic_data [as 别名]
def test_generate_synethetic_data(self):
input_element, label_element = model_helpers.generate_synthetic_data(
input_shape=tf.TensorShape([5]),
input_value=123,
input_dtype=tf.float32,
label_shape=tf.TensorShape([]),
label_value=456,
label_dtype=tf.int32).make_one_shot_iterator().get_next()
with self.test_session() as sess:
for n in range(5):
inp, lab = sess.run((input_element, label_element))
self.assertAllClose(inp, [123., 123., 123., 123., 123.])
self.assertEquals(lab, 456)
示例5: test_generate_only_input_data
# 需要导入模块: from official.utils.misc import model_helpers [as 别名]
# 或者: from official.utils.misc.model_helpers import generate_synthetic_data [as 别名]
def test_generate_only_input_data(self):
d = model_helpers.generate_synthetic_data(
input_shape=tf.TensorShape([4]),
input_value=43.5,
input_dtype=tf.float32)
element = d.make_one_shot_iterator().get_next()
self.assertFalse(isinstance(element, tuple))
with self.test_session() as sess:
inp = sess.run(element)
self.assertAllClose(inp, [43.5, 43.5, 43.5, 43.5])
示例6: _generate_synthetic_data
# 需要导入模块: from official.utils.misc import model_helpers [as 别名]
# 或者: from official.utils.misc.model_helpers import generate_synthetic_data [as 别名]
def _generate_synthetic_data(params):
"""Create synthetic data based on the parameter batch size."""
batch = length = int(math.sqrt(params["batch_size"]))
return model_helpers.generate_synthetic_data(
input_shape=tf.TensorShape([batch, length]),
input_value=1,
input_dtype=tf.int32,
label_shape=tf.TensorShape([batch, length]),
label_value=1,
label_dtype=tf.int32,
)
示例7: test_generate_synethetic_data
# 需要导入模块: from official.utils.misc import model_helpers [as 别名]
# 或者: from official.utils.misc.model_helpers import generate_synthetic_data [as 别名]
def test_generate_synethetic_data(self):
input_element, label_element = tf.compat.v1.data.make_one_shot_iterator(
model_helpers.generate_synthetic_data(input_shape=tf.TensorShape([5]),
input_value=123,
input_dtype=tf.float32,
label_shape=tf.TensorShape([]),
label_value=456,
label_dtype=tf.int32)).get_next()
with self.session() as sess:
for n in range(5):
inp, lab = sess.run((input_element, label_element))
self.assertAllClose(inp, [123., 123., 123., 123., 123.])
self.assertEquals(lab, 456)
开发者ID:ShivangShekhar,项目名称:Live-feed-object-device-identification-using-Tensorflow-and-OpenCV,代码行数:16,代码来源:model_helpers_test.py
示例8: test_generate_only_input_data
# 需要导入模块: from official.utils.misc import model_helpers [as 别名]
# 或者: from official.utils.misc.model_helpers import generate_synthetic_data [as 别名]
def test_generate_only_input_data(self):
d = model_helpers.generate_synthetic_data(
input_shape=tf.TensorShape([4]),
input_value=43.5,
input_dtype=tf.float32)
element = tf.compat.v1.data.make_one_shot_iterator(d).get_next()
self.assertFalse(isinstance(element, tuple))
with self.session() as sess:
inp = sess.run(element)
self.assertAllClose(inp, [43.5, 43.5, 43.5, 43.5])
开发者ID:ShivangShekhar,项目名称:Live-feed-object-device-identification-using-Tensorflow-and-OpenCV,代码行数:14,代码来源:model_helpers_test.py
示例9: _generate_synthetic_data
# 需要导入模块: from official.utils.misc import model_helpers [as 别名]
# 或者: from official.utils.misc.model_helpers import generate_synthetic_data [as 别名]
def _generate_synthetic_data(params):
"""Create synthetic data based on the parameter batch size."""
batch = length = int(math.sqrt(params["batch_size"]))
dataset = model_helpers.generate_synthetic_data(
input_shape=tf.TensorShape([length]),
input_value=1,
input_dtype=tf.int64,
label_shape=tf.TensorShape([length]),
label_value=1,
label_dtype=tf.int64,
)
return dataset.batch(batch, drop_remainder=True)
开发者ID:ShivangShekhar,项目名称:Live-feed-object-device-identification-using-Tensorflow-and-OpenCV,代码行数:14,代码来源:data_pipeline.py