當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。