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


Python input.limit_epochs函数代码示例

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


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

示例1: _fn

    def _fn():
      x = constant_op.constant(points)
      if batch_size == num_points:
        return input_lib.limit_epochs(x, num_epochs=num_epochs), None
      if randomize:
        indices = random_ops.random_uniform(
            constant_op.constant([batch_size]),
            minval=0,
            maxval=num_points - 1,
            dtype=dtypes.int32,
            seed=10)
      else:
        # We need to cycle through the indices sequentially. We create a queue
        # to maintain the list of indices.
        q = data_flow_ops.FIFOQueue(num_points, dtypes.int32, ())

        # Conditionally initialize the Queue.
        def _init_q():
          with ops.control_dependencies(
              [q.enqueue_many(math_ops.range(num_points))]):
            return control_flow_ops.no_op()

        init_q = control_flow_ops.cond(q.size() <= 0, _init_q,
                                       control_flow_ops.no_op)
        with ops.control_dependencies([init_q]):
          offsets = q.dequeue_many(batch_size)
          with ops.control_dependencies([q.enqueue_many(offsets)]):
            indices = array_ops.identity(offsets)
      batch = array_ops.gather(x, indices)
      return (input_lib.limit_epochs(batch, num_epochs=num_epochs), None)
开发者ID:AndrewTwinz,项目名称:tensorflow,代码行数:30,代码来源:kmeans_test.py

示例2: testWithEpochLimit

  def testWithEpochLimit(self):
    predictions_limited = input.limit_epochs(self._predictions, num_epochs=1)
    labels_limited = input.limit_epochs(self._labels, num_epochs=1)

    value_op, update_op = metric_ops.streaming_accuracy(
        predictions_limited, labels_limited)

    init_op = control_flow_ops.group(variables.global_variables_initializer(),
                                     variables.local_variables_initializer())
    # Create checkpoint and log directories:
    chkpt_dir = os.path.join(self.get_temp_dir(), 'tmp_logs/')
    gfile.MakeDirs(chkpt_dir)
    logdir = os.path.join(self.get_temp_dir(), 'tmp_logs2/')
    gfile.MakeDirs(logdir)

    # Save initialized variables to a checkpoint directory:
    saver = saver_lib.Saver()
    with self.test_session() as sess:
      init_op.run()
      saver.save(sess, os.path.join(chkpt_dir, 'chkpt'))

    # Now, run the evaluation loop:
    accuracy_value = evaluation.evaluation_loop(
        '', chkpt_dir, logdir, eval_op=update_op, final_op=value_op,
        max_number_of_evaluations=1, num_evals=10000)
    self.assertAlmostEqual(accuracy_value, self._expected_accuracy)
开发者ID:AbhinavJain13,项目名称:tensorflow,代码行数:26,代码来源:evaluation_test.py

示例3: _fn

 def _fn():
   x = constant_op.constant(points)
   if batch_size == num_points:
     return input_lib.limit_epochs(x, num_epochs=num_epochs), None
   indices = random_ops.random_uniform(
       constant_op.constant([batch_size]),
       minval=0,
       maxval=num_points - 1,
       dtype=dtypes.int32,
       seed=10)
   batch = array_ops.gather(x, indices)
   return (input_lib.limit_epochs(batch, num_epochs=num_epochs), None)
开发者ID:AliMiraftab,项目名称:tensorflow,代码行数:12,代码来源:kmeans_test.py

示例4: _input_fn

 def _input_fn(num_epochs=None):
   features = {
       'age':
           input_lib.limit_epochs(
               constant_op.constant([[0.8], [0.15], [0.]]),
               num_epochs=num_epochs),
       'language':
           sparse_tensor.SparseTensor(
               values=input_lib.limit_epochs(
                   ['en', 'fr', 'zh'], num_epochs=num_epochs),
               indices=[[0, 0], [0, 1], [2, 0]],
               dense_shape=[3, 2])
   }
   return features, constant_op.constant([1., 0., 0.2], dtype=dtypes.float32)
开发者ID:eduardofv,项目名称:tensorflow,代码行数:14,代码来源:debug_test.py

示例5: _input_fn

 def _input_fn(num_epochs=None):
   features = {
       'age':
           input_lib.limit_epochs(
               constant_op.constant(((50,), (20,), (10,))),
               num_epochs=num_epochs),
       'language':
           sparse_tensor.SparseTensor(
               values=input_lib.limit_epochs(
                   ('en', 'fr', 'zh'), num_epochs=num_epochs),
               indices=((0, 0), (0, 1), (2, 0)),
               dense_shape=(3, 2))
   }
   return features, constant_op.constant(
       ((0.8,), (0.,), (0.2,)), dtype=dtypes.float32)
开发者ID:AlbertXiebnu,项目名称:tensorflow,代码行数:15,代码来源:dnn_benchmark_test.py

示例6: _predict_input_fn

 def _predict_input_fn():
   feature_map = parsing_ops.parse_example(
       input_lib.limit_epochs(serialized_examples, num_epochs=1),
       feature_spec)
   features = _queue_parsed_features(feature_map)
   features.pop('y')
   return features, None
开发者ID:AndrewTwinz,项目名称:tensorflow,代码行数:7,代码来源:dnn_test.py

示例7: _eval_input_fn

 def _eval_input_fn():
   feature_map = parsing_ops.parse_example(
       input_lib.limit_epochs(serialized_examples, num_epochs=1),
       feature_spec)
   features = linear_testing_utils.queue_parsed_features(feature_map)
   labels = features.pop('y')
   return features, labels
开发者ID:1000sprites,项目名称:tensorflow,代码行数:7,代码来源:dnn_linear_combined_test.py

示例8: boston_input_fn

def boston_input_fn(num_epochs=None):
  boston = base.load_boston()
  features = input_lib.limit_epochs(
      array_ops.reshape(
          constant_op.constant(boston.data), [-1, _BOSTON_INPUT_DIM]),
      num_epochs=num_epochs)
  labels = array_ops.reshape(constant_op.constant(boston.target), [-1, 1])
  return features, labels
开发者ID:Immexxx,项目名称:tensorflow,代码行数:8,代码来源:estimator_test.py

示例9: testTrainWithEpochLimit

  def testTrainWithEpochLimit(self):
    logdir = os.path.join(tempfile.mkdtemp(prefix=self.get_temp_dir()),
                          'tmp_logs')
    with ops.Graph().as_default():
      random_seed.set_random_seed(0)
      tf_inputs = constant_op.constant(self._inputs, dtype=dtypes.float32)
      tf_labels = constant_op.constant(self._labels, dtype=dtypes.float32)
      tf_inputs_limited = input_lib.limit_epochs(tf_inputs, num_epochs=300)
      tf_labels_limited = input_lib.limit_epochs(tf_labels, num_epochs=300)

      tf_predictions = LogisticClassifier(tf_inputs_limited)
      loss_ops.log_loss(tf_predictions, tf_labels_limited)
      total_loss = loss_ops.get_total_loss()

      optimizer = gradient_descent.GradientDescentOptimizer(learning_rate=1.0)

      train_op = learning.create_train_op(total_loss, optimizer)

      loss = learning.train(train_op, logdir, log_every_n_steps=10)
    self.assertIsNotNone(loss)
    self.assertLess(loss, .015)
    self.assertTrue(os.path.isfile('{}/model.ckpt-300.index'.format(logdir)))
    self.assertTrue(os.path.isfile('{}/model.ckpt-300.data-00000-of-00001'.format(logdir)))
开发者ID:Immexxx,项目名称:tensorflow,代码行数:23,代码来源:learning_test.py

示例10: _input_fn

 def _input_fn():
   return (input_lib.limit_epochs(
       constant_op.constant(points), num_epochs=1), None)
开发者ID:AndrewTwinz,项目名称:tensorflow,代码行数:3,代码来源:kmeans_test.py

示例11: _input_fn

 def _input_fn(instances):
     features = {
         'features':
             input_lib.limit_epochs(tf.constant(instances), num_epochs=1)
     }
     return features, None
开发者ID:ckml,项目名称:tf_learn,代码行数:6,代码来源:custom_cnn.py

示例12: _predict_input_fn

 def _predict_input_fn():
   features = parsing_ops.parse_example(
       input_lib.limit_epochs(serialized_examples, num_epochs=1),
       feature_spec)
   features.pop('label')
   return features, None
开发者ID:bikong2,项目名称:tensorflow,代码行数:6,代码来源:rnn_test.py

示例13: _eval_input_fn

 def _eval_input_fn():
   features = parsing_ops.parse_example(
       input_lib.limit_epochs(serialized_examples, num_epochs=1),
       feature_spec)
   labels = features.pop('label')
   return features, labels
开发者ID:bikong2,项目名称:tensorflow,代码行数:6,代码来源:rnn_test.py


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