• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python queue_runner_impl.add_queue_runner函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tensorflow.python.training.queue_runner_impl.add_queue_runner函数的典型用法代码示例。如果您正苦于以下问题:Python add_queue_runner函数的具体用法?Python add_queue_runner怎么用?Python add_queue_runner使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了add_queue_runner函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: testName

 def testName(self):
   with ops.name_scope("scope"):
     queue = data_flow_ops.FIFOQueue(10, dtypes.float32, name="queue")
   qr = queue_runner_impl.QueueRunner(queue, [control_flow_ops.no_op()])
   self.assertEqual("scope/queue", qr.name)
   queue_runner_impl.add_queue_runner(qr)
   self.assertEqual(
       1, len(ops.get_collection(ops.GraphKeys.QUEUE_RUNNERS, "scope")))
开发者ID:ThunderQi,项目名称:tensorflow,代码行数:8,代码来源:queue_runner_test.py


示例2: boston_input_fn_with_queue

def boston_input_fn_with_queue(num_epochs=None):
  features, labels = boston_input_fn(num_epochs=num_epochs)

  # Create a minimal queue runner.
  fake_queue = data_flow_ops.FIFOQueue(30, dtypes.int32)
  queue_runner = queue_runner_impl.QueueRunner(fake_queue,
                                               [constant_op.constant(0)])
  queue_runner_impl.add_queue_runner(queue_runner)

  return features, labels
开发者ID:Immexxx,项目名称:tensorflow,代码行数:10,代码来源:estimator_test.py


示例3: testStartQueueRunnersRaisesIfNotASession

 def testStartQueueRunnersRaisesIfNotASession(self):
   zero64 = constant_op.constant(0, dtype=dtypes.int64)
   var = variables.VariableV1(zero64)
   count_up_to = var.count_up_to(3)
   queue = data_flow_ops.FIFOQueue(10, dtypes.float32)
   init_op = variables.global_variables_initializer()
   qr = queue_runner_impl.QueueRunner(queue, [count_up_to])
   queue_runner_impl.add_queue_runner(qr)
   with self.cached_session():
     init_op.run()
     with self.assertRaisesRegexp(TypeError, "tf.Session"):
       queue_runner_impl.start_queue_runners("NotASession")
开发者ID:ThunderQi,项目名称:tensorflow,代码行数:12,代码来源:queue_runner_test.py


示例4: testStartQueueRunnersIgnoresMonitoredSession

 def testStartQueueRunnersIgnoresMonitoredSession(self):
   zero64 = constant_op.constant(0, dtype=dtypes.int64)
   var = variables.VariableV1(zero64)
   count_up_to = var.count_up_to(3)
   queue = data_flow_ops.FIFOQueue(10, dtypes.float32)
   init_op = variables.global_variables_initializer()
   qr = queue_runner_impl.QueueRunner(queue, [count_up_to])
   queue_runner_impl.add_queue_runner(qr)
   with self.cached_session():
     init_op.run()
     threads = queue_runner_impl.start_queue_runners(
         monitored_session.MonitoredSession())
     self.assertFalse(threads)
开发者ID:ThunderQi,项目名称:tensorflow,代码行数:13,代码来源:queue_runner_test.py


示例5: _testScopedExportWithQueue

  def _testScopedExportWithQueue(self, test_dir, exported_filename):
    graph = ops.Graph()
    with graph.as_default():
      with ops.name_scope("queue1"):
        input_queue = data_flow_ops.FIFOQueue(10, dtypes.float32)
        enqueue = input_queue.enqueue((9876), name="enqueue")
        close = input_queue.close(name="close")
        qr = queue_runner_impl.QueueRunner(input_queue, [enqueue], close)
        queue_runner_impl.add_queue_runner(qr)
        input_queue.dequeue(name="dequeue")

      orig_meta_graph, _ = meta_graph.export_scoped_meta_graph(
          filename=os.path.join(test_dir, exported_filename),
          graph=ops.get_default_graph(),
          export_scope="queue1")

    return orig_meta_graph
开发者ID:AlbertXiebnu,项目名称:tensorflow,代码行数:17,代码来源:meta_graph_test.py


示例6: testStartQueueRunners

 def testStartQueueRunners(self):
   # CountUpTo will raise OUT_OF_RANGE when it reaches the count.
   zero64 = constant_op.constant(0, dtype=dtypes.int64)
   var = variables.VariableV1(zero64)
   count_up_to = var.count_up_to(3)
   queue = data_flow_ops.FIFOQueue(10, dtypes.float32)
   init_op = variables.global_variables_initializer()
   qr = queue_runner_impl.QueueRunner(queue, [count_up_to])
   queue_runner_impl.add_queue_runner(qr)
   with self.cached_session() as sess:
     init_op.run()
     threads = queue_runner_impl.start_queue_runners(sess)
     for t in threads:
       t.join()
     self.assertEqual(0, len(qr.exceptions_raised))
     # The variable should be 3.
     self.assertEqual(3, var.eval())
开发者ID:ThunderQi,项目名称:tensorflow,代码行数:17,代码来源:queue_runner_test.py


示例7: testMultiThreadedEstimateDataDistribution

  def testMultiThreadedEstimateDataDistribution(self):
    num_classes = 10

    # Set up graph.
    random_seed.set_random_seed(1234)
    label = math_ops.cast(
        math_ops.round(random_ops.random_uniform([1]) * num_classes),
        dtypes_lib.int32)

    prob_estimate = sampling_ops._estimate_data_distribution(  # pylint: disable=protected-access
        label, num_classes)
    # Check that prob_estimate is well-behaved in a multithreaded context.
    _, _, [prob_estimate] = sampling_ops._verify_input(  # pylint: disable=protected-access
        [], label, [prob_estimate])

    # Use queues to run multiple threads over the graph, each of which
    # fetches `prob_estimate`.
    queue = data_flow_ops.FIFOQueue(
        capacity=25,
        dtypes=[prob_estimate.dtype],
        shapes=[prob_estimate.get_shape()])
    enqueue_op = queue.enqueue([prob_estimate])
    queue_runner_impl.add_queue_runner(
        queue_runner_impl.QueueRunner(queue, [enqueue_op] * 25))
    out_tensor = queue.dequeue()

    # Run the multi-threaded session.
    with self.cached_session() as sess:
      # Need to initialize variables that keep running total of classes seen.
      variables.global_variables_initializer().run()

      coord = coordinator.Coordinator()
      threads = queue_runner_impl.start_queue_runners(coord=coord)

      for _ in range(25):
        sess.run([out_tensor])

      coord.request_stop()
      coord.join(threads)
开发者ID:Ajaycs99,项目名称:tensorflow,代码行数:39,代码来源:sampling_ops_threading_test.py



注:本文中的tensorflow.python.training.queue_runner_impl.add_queue_runner函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap