当前位置: 首页>>代码示例>>Python>>正文


Python tensorflow.QueueBase方法代码示例

本文整理汇总了Python中tensorflow.QueueBase方法的典型用法代码示例。如果您正苦于以下问题:Python tensorflow.QueueBase方法的具体用法?Python tensorflow.QueueBase怎么用?Python tensorflow.QueueBase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tensorflow的用法示例。


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

示例1: __init__

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import QueueBase [as 别名]
def __init__(self, config, input_queue=None, predict_tower=None):
        """
        :param config: a `TrainConfig` instance
        :param input_queue: a `tf.QueueBase` instance to be used to buffer datapoints.
            Defaults to a FIFO queue of size 100.
        :param predict_tower: list of gpu relative idx to run prediction. default to be [0].
            Use -1 for cpu.
        """
        super(QueueInputTrainer, self).__init__(config)
        self.input_vars = self.model.get_input_vars()
        # use a smaller queue size for now, to avoid https://github.com/tensorflow/tensorflow/issues/2942
        if input_queue is None:
            self.input_queue = tf.FIFOQueue(
                    50, [x.dtype for x in self.input_vars], name='input_queue')
        else:
            self.input_queue = input_queue

        # by default, use the first training gpu for prediction
        self.predict_tower = predict_tower or [0]
        self.dequed_inputs = None 
开发者ID:mihahauke,项目名称:VDAIC2017,代码行数:22,代码来源:trainer.py

示例2: __init__

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import QueueBase [as 别名]
def __init__(self, config, input_queue=None, predict_tower=None):
        """
        :param config: a `TrainConfig` instance
        :param input_queue: a `tf.QueueBase` instance to be used to buffer datapoints.
            Defaults to a FIFO queue of size 100.
        :param predict_tower: list of gpu relative idx to run prediction. default to be [0].
            Use -1 for cpu.
        """
        super(QueueInputTrainer, self).__init__(config)
        self.input_vars = self.model.get_input_vars()
        # use a smaller queue size for now, to avoid https://github.com/tensorflow/tensorflow/issues/2942


        queue_size = config.extra_arg['queue_size']
        self.dummy_predictor = config.extra_arg['dummy_predictor']
        print 'DUMMY PREDICTOR', self.dummy_predictor

        if input_queue is None:
            self.input_queue = tf.FIFOQueue(
                    queue_size, [x.dtype for x in self.input_vars], name='input_queue')
        else:
            self.input_queue = input_queue

        # by default, use the first training gpu for prediction
        self.predict_tower = predict_tower or [0]
        self.dequed_inputs = None


        self.queue_size_op = self.input_queue.size() 
开发者ID:anonymous-author1,项目名称:DDRL,代码行数:31,代码来源:trainer.py

示例3: __init__

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import QueueBase [as 别名]
def __init__(self, ds, queue=None):
        """
        Args:
            ds(DataFlow): the input DataFlow.
            queue (tf.QueueBase): A :class:`tf.QueueBase` whose type
                should match the corresponding input signature of the model.
                Defaults to a FIFO queue of size 50.
        """
        if not isinstance(ds, DataFlow):
            raise ValueError("QueueInput takes a DataFlow! Got {}".format(ds))
        self.queue = queue
        self.ds = ds
        self._inf_ds = RepeatedData(ds, -1)
        self._started = False 
开发者ID:microsoft,项目名称:petridishnn,代码行数:16,代码来源:input_source.py

示例4: test_init_loom

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import QueueBase [as 别名]
def test_init_loom(self):
    p = plan.TrainPlan()
    p.compiler = block_compiler.Compiler().compile(blocks.Scalar())
    p.batch_size = 3
    p.task = 13
    p.num_dequeuers = 7

    self.assertRaisesWithLiteralMatch(
        ValueError, 'must have at least one PS task; 0', p.init_loom)

    p.ps_tasks = 5
    self.assertRaisesWithLiteralMatch(
        ValueError, 'worker_replicas must be at least num_queues + '
        'num_dequeuers; 0 vs. 5 + 7 = 12', p.init_loom)
    p.worker_replicas = 14

    # Would be best to actually create a queue and inspect it, but
    # tf.QueueBase doesn't currently expose these properties.
    self.assertEqual(p._create_queue(3, ctor=dict)['capacity'], 12)
    p.queue_capacity = 42
    q_dict = p._create_queue(3, ctor=dict)
    self.assertEqual(q_dict['capacity'], 42)
    self.assertEqual(q_dict['shared_name'], 'tensorflow_fold_plan_queue3')

    self.assertEqual(p.init_loom(), (True, False))

    p.compiler = block_compiler.Compiler().compile(blocks.Scalar())
    p.task = 3
    self.assertEqual(p.init_loom(), (False, True))

    p.compiler = block_compiler.Compiler().compile(blocks.Scalar())
    p.num_dequeuers = 0
    self.assertRaisesWithLiteralMatch(
        ValueError, 'cannot specify queue_capacity without also '
        'specifying num_dequeuers', p.init_loom)

    p.compiler = block_compiler.Compiler().compile(blocks.Scalar())
    p.queue_capacity = 0
    self.assertEqual(p.init_loom(), (True, True)) 
开发者ID:tensorflow,项目名称:fold,代码行数:41,代码来源:plan_test.py


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