本文整理汇总了Python中tensorflow.contrib.data.python.ops.stats_ops.latency_stats函数的典型用法代码示例。如果您正苦于以下问题:Python latency_stats函数的具体用法?Python latency_stats怎么用?Python latency_stats使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了latency_stats函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_latency_stats_invalid_tag_shape
def test_latency_stats_invalid_tag_shape(self):
with self.assertRaisesRegexp(
ValueError, 'Shape must be rank 0 but is rank 1'):
self.run_core_tests(
lambda: dataset_ops.Dataset.range(100).apply(
stats_ops.latency_stats(["record_latency", "record_latency_2"])),
None, 100)
示例2: testRepeatedTags
def testRepeatedTags(self):
stats_aggregator = stats_ops.StatsAggregator()
dataset = dataset_ops.Dataset.range(100).apply(
stats_ops.latency_stats("record_latency")).apply(
stats_ops.latency_stats("record_latency")).apply(
stats_ops.set_stats_aggregator(stats_aggregator))
iterator = dataset.make_initializable_iterator()
next_element = iterator.get_next()
summary_t = stats_aggregator.get_summary()
with self.test_session() as sess:
sess.run(iterator.initializer)
for i in range(100):
self.assertEqual(i, sess.run(next_element))
self._assertSummaryHasCount(
sess.run(summary_t), "record_latency", float(2 * (i + 1)))
with self.assertRaises(errors.OutOfRangeError):
sess.run(next_element)
self._assertSummaryHasCount(sess.run(summary_t), "record_latency", 200.0)
示例3: testNoAggregatorRegistered
def testNoAggregatorRegistered(self):
dataset = dataset_ops.Dataset.range(100).apply(
stats_ops.latency_stats("record_latency"))
iterator = dataset.make_initializable_iterator()
next_element = iterator.get_next()
with self.test_session() as sess:
sess.run(iterator.initializer)
for i in range(100):
self.assertEqual(i, sess.run(next_element))
with self.assertRaises(errors.OutOfRangeError):
sess.run(next_element)
示例4: testMultipleStatsAggregatorsSameIteratorFail
def testMultipleStatsAggregatorsSameIteratorFail(self):
dataset = dataset_ops.Dataset.range(100).apply(
stats_ops.latency_stats("record_latency"))
iterator = dataset.make_initializable_iterator()
stats_aggregator_0 = stats_ops.StatsAggregator()
stats_aggregator_1 = stats_ops.StatsAggregator()
with self.test_session() as sess:
sess.run(stats_aggregator_0.subscribe(iterator))
# TODO(mrry): Consider making this allowable (and also allowing
# aggregators to unsubscribe).
with self.assertRaises(errors.FailedPreconditionError):
sess.run(stats_aggregator_1.subscribe(iterator))
示例5: testMultipleTags
def testMultipleTags(self):
dataset = dataset_ops.Dataset.range(100).apply(
stats_ops.latency_stats("record_latency")).apply(
stats_ops.latency_stats("record_latency_2"))
iterator = dataset.make_initializable_iterator()
stats_aggregator = stats_ops.StatsAggregator()
stats_aggregator_subscriber = stats_aggregator.subscribe(iterator)
next_element = iterator.get_next()
summary_t = stats_aggregator.get_summary()
with self.test_session() as sess:
sess.run([iterator.initializer, stats_aggregator_subscriber])
for i in range(100):
self.assertEqual(i, sess.run(next_element))
self._assertSummaryHasCount(
sess.run(summary_t), "record_latency", float(i + 1))
self._assertSummaryHasCount(
sess.run(summary_t), "record_latency_2", float(i + 1))
with self.assertRaises(errors.OutOfRangeError):
sess.run(next_element)
self._assertSummaryHasCount(sess.run(summary_t), "record_latency", 100.0)
self._assertSummaryHasCount(
sess.run(summary_t), "record_latency_2", 100.0)
示例6: testMultipleIteratorsSameAggregator
def testMultipleIteratorsSameAggregator(self):
stats_aggregator = stats_ops.StatsAggregator()
dataset = dataset_ops.Dataset.range(100).apply(
stats_ops.latency_stats("record_latency")).apply(
stats_ops.set_stats_aggregator(stats_aggregator))
iterator_0 = dataset.make_initializable_iterator()
iterator_1 = dataset.make_initializable_iterator()
next_element = iterator_0.get_next() + iterator_1.get_next()
summary_t = stats_aggregator.get_summary()
with self.cached_session() as sess:
sess.run([iterator_0.initializer, iterator_1.initializer])
for i in range(100):
self.assertEqual(i * 2, sess.run(next_element))
self._assertSummaryHasCount(
sess.run(summary_t), "record_latency", float(2 * (i + 1)))
with self.assertRaises(errors.OutOfRangeError):
sess.run(next_element)
self._assertSummaryHasCount(sess.run(summary_t), "record_latency", 200.0)
示例7: _build_dataset_multiple_tags
def _build_dataset_multiple_tags(self,
num_elements,
tag1="record_latency",
tag2="record_latency_2"):
return dataset_ops.Dataset.range(num_elements).apply(
stats_ops.latency_stats(tag1)).apply(stats_ops.latency_stats(tag2))
示例8: _build_dataset_latency_stats
def _build_dataset_latency_stats(self, num_elements, tag="record_latency"):
return dataset_ops.Dataset.range(num_elements).apply(
stats_ops.latency_stats(tag))