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

Python data_feeder.setup_train_data_feeder函数代码示例

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

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



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

示例1: _get_input_fn

def _get_input_fn(x, y, input_fn, feed_fn, batch_size, shuffle=False, epochs=1):
  """Make inputs into input and feed functions."""
  if input_fn is None:
    if x is None:
      raise ValueError('Either x or input_fn must be provided.')

    if contrib_framework.is_tensor(x) or (y is not None and
                                          contrib_framework.is_tensor(y)):
      raise ValueError('Inputs cannot be tensors. Please provide input_fn.')

    if feed_fn is not None:
      raise ValueError('Can not provide both feed_fn and x or y.')

    df = data_feeder.setup_train_data_feeder(x, y, n_classes=None,
                                             batch_size=batch_size,
                                             shuffle=shuffle,
                                             epochs=epochs)
    return df.input_builder, df.get_feed_dict_fn()

  if (x is not None) or (y is not None):
    raise ValueError('Can not provide both input_fn and x or y.')
  if batch_size is not None:
    raise ValueError('Can not provide both input_fn and batch_size.')

  return input_fn, feed_fn
开发者ID:Nishant23,项目名称:tensorflow,代码行数:25,代码来源:estimator.py


示例2: evaluate

  def evaluate(self,
               x=None,
               y=None,
               input_fn=None,
               feed_fn=None,
               batch_size=None,
               steps=None,
               metrics=None,
               name=None):
    """Evaluates given model with provided evaluation data.

    See superclass Estimator for more details.

    Args:
      x: features.
      y: targets.
      input_fn: Input function.
      feed_fn: Function creating a feed dict every time it is called.
      batch_size: minibatch size to use on the input.
      steps: Number of steps for which to evaluate model.
      metrics: Dict of metric ops to run. If None, the default metrics are used.
      name: Name of the evaluation.

    Returns:
      Returns `dict` with evaluation results.
    """
    feed_fn = None
    if x is not None:
      eval_data_feeder = setup_train_data_feeder(
          x, y, n_classes=self.n_classes, batch_size=self.batch_size, epochs=1)
      input_fn, feed_fn = (eval_data_feeder.input_builder,
                           eval_data_feeder.get_feed_dict_fn())
    return self._evaluate_model(
        input_fn=input_fn, feed_fn=feed_fn, steps=steps or self.steps,
        name=name)
开发者ID:JamesFysh,项目名称:tensorflow,代码行数:35,代码来源:base.py


示例3: fit

  def fit(self, x, y=None, monitors=None, logdir=None, steps=None, batch_size=128):
    """Trains a k-means clustering on x.

    Note: See Estimator for logic for continuous training and graph
      construction across multiple calls to fit.

    Args:
      x: training input matrix of shape [n_samples, n_features].
      y: labels. Should be None.
      monitors: Monitor object to print training progress and invoke early
        stopping
      logdir: the directory to save the log file that can be used for optional
        visualization.
      steps: number of training steps. If not None, overrides the value passed
        in constructor.

    Returns:
      Returns self.
    """
    assert y is None
    if logdir is not None:
      self._model_dir = logdir
    self._data_feeder = data_feeder.setup_train_data_feeder(
        x, None, self._num_clusters, batch_size)
    self._train_model(input_fn=self._data_feeder.input_builder,
                      feed_fn=self._data_feeder.get_feed_dict_fn(),
                      steps=steps,
                      monitors=monitors,
                      init_feed_fn=self._data_feeder.get_feed_dict_fn())
    return self
开发者ID:31H0B1eV,项目名称:tensorflow,代码行数:30,代码来源:kmeans.py


示例4: fit

  def fit(self, x, y, steps=None, monitors=None, logdir=None):
    """Neural network model from provided `model_fn` and training data.

    Note: called first time constructs the graph and initializers
    variables. Consecutives times it will continue training the same model.
    This logic follows partial_fit() interface in scikit-learn.
    To restart learning, create new estimator.

    Args:
      x: matrix or tensor of shape [n_samples, n_features...]. Can be
      iterator that returns arrays of features. The training input
      samples for fitting the model.
      y: vector or matrix [n_samples] or [n_samples, n_outputs]. Can be
      iterator that returns array of targets. The training target values
      (class labels in classification, real numbers in regression).
      steps: int, number of steps to train.
             If None or 0, train for `self.steps`.
      monitors: List of `BaseMonitor` objects to print training progress and
        invoke early stopping.
      logdir: the directory to save the log file that can be used for
      optional visualization.

    Returns:
      Returns self.
    """
    if logdir is not None:
      self._model_dir = logdir
    self._data_feeder = setup_train_data_feeder(
        x, y, n_classes=self.n_classes, batch_size=self.batch_size)
    self._train_model(input_fn=self._data_feeder.input_builder,
                      feed_fn=self._data_feeder.get_feed_dict_fn(),
                      steps=steps or self.steps,
                      monitors=monitors)
    return self
开发者ID:JamesFysh,项目名称:tensorflow,代码行数:34,代码来源:base.py


示例5: evaluate

 def evaluate(self, x=None, y=None, input_fn=None, steps=None):
   """See base class."""
   feed_fn = None
   if x is not None:
     eval_data_feeder = setup_train_data_feeder(
         x, y, n_classes=self.n_classes, batch_size=self.batch_size, epochs=1)
     input_fn, feed_fn = (eval_data_feeder.input_builder,
                          eval_data_feeder.get_feed_dict_fn())
   return self._evaluate_model(
       input_fn=input_fn, feed_fn=feed_fn, steps=steps or self.steps)
开发者ID:2020zyc,项目名称:tensorflow,代码行数:10,代码来源:base.py


示例6: predict

 def predict(self, x=None, input_fn=None, batch_size=None, outputs=None,
             axis=1):
   """Predict class or regression for `x`."""
   if x is not None:
     predict_data_feeder = setup_train_data_feeder(
         x, None, n_classes=None,
         batch_size=batch_size or self.batch_size,
         shuffle=False, epochs=1)
     result = super(DeprecatedMixin, self)._infer_model(
         input_fn=predict_data_feeder.input_builder,
         feed_fn=predict_data_feeder.get_feed_dict_fn(),
         outputs=outputs)
   else:
     result = super(DeprecatedMixin, self)._infer_model(
         input_fn=input_fn, outputs=outputs)
   if self.__deprecated_n_classes > 1 and axis is not None:
     return np.argmax(result, axis)
   return result
开发者ID:AriaAsuka,项目名称:tensorflow,代码行数:18,代码来源:base.py


示例7: fit

  def fit(self, x, y=None, monitors=None, logdir=None, steps=None, batch_size=128,
          relative_tolerance=None):
    """Trains a k-means clustering on x.

    Note: See Estimator for logic for continuous training and graph
      construction across multiple calls to fit.

    Args:
      x: training input matrix of shape [n_samples, n_features].
      y: labels. Should be None.
      monitors: Monitor object to print training progress and invoke early
        stopping
      logdir: the directory to save the log file that can be used for optional
        visualization.
      steps: number of training steps. If not None, overrides the value passed
        in constructor.
      batch_size: mini-batch size to use. Requires `use_mini_batch=True`.
      relative_tolerance: A relative tolerance of change in the loss between
        iterations.  Stops learning if the loss changes less than this amount.
        Note that this may not work correctly if use_mini_batch=True.

    Returns:
      Returns self.
    """
    assert y is None
    if logdir is not None:
      self._model_dir = logdir
    self._data_feeder = data_feeder.setup_train_data_feeder(
        x, None, self._num_clusters, batch_size if self._use_mini_batch else None)
    if relative_tolerance is not None:
      if monitors is not None:
        monitors += [self._StopWhenConverged(relative_tolerance)]
      else:
        monitors = [self._StopWhenConverged(relative_tolerance)]
    # Make sure that we will eventually terminate.
    assert ((monitors is not None and len(monitors)) or (steps is not None)
            or (self.steps is not None))
    self._train_model(input_fn=self._data_feeder.input_builder,
                      feed_fn=self._data_feeder.get_feed_dict_fn(),
                      steps=steps,
                      monitors=monitors,
                      init_feed_fn=self._data_feeder.get_feed_dict_fn())
    return self
开发者ID:821760408-sp,项目名称:tensorflow,代码行数:43,代码来源:kmeans.py


示例8: _predict

  def _predict(self, x, axis=-1, batch_size=None):
    if self._graph is None:
      raise NotFittedError()
    # Use the batch size for fitting if the user did not specify one.
    if batch_size is None:
      batch_size = self.batch_size

    predict_data_feeder = setup_train_data_feeder(
        x, None, n_classes=None,
        batch_size=batch_size,
        shuffle=False, epochs=1)

    preds = np.array(list(self._infer_model(
        input_fn=predict_data_feeder.input_builder,
        feed_fn=predict_data_feeder.get_feed_dict_fn(),
        as_iterable=True)))
    if self.n_classes > 1 and axis != -1:
      preds = preds.argmax(axis=axis)
    return preds
开发者ID:JamesFysh,项目名称:tensorflow,代码行数:19,代码来源:base.py


示例9: _get_input_fn

def _get_input_fn(x, y, input_fn, feed_fn, batch_size, shuffle=False, epochs=1):
  """Make inputs into input and feed functions.

  Args:
    x: Numpy, Pandas or Dask matrix or iterable.
    y: Numpy, Pandas or Dask matrix or iterable.
    input_fn: Pre-defined input function for training data.
    feed_fn: Pre-defined data feeder function.
    batch_size: Size to split data into parts. Must be >= 1.
    shuffle: Whether to shuffle the inputs.
    epochs: Number of epochs to run.

  Returns:
    Data input and feeder function based on training data.

  Raises:
    ValueError: Only one of `(x & y)` or `input_fn` must be provided.
  """
  if input_fn is None:
    if x is None:
      raise ValueError('Either x or input_fn must be provided.')

    if contrib_framework.is_tensor(x) or (y is not None and
                                          contrib_framework.is_tensor(y)):
      raise ValueError('Inputs cannot be tensors. Please provide input_fn.')

    if feed_fn is not None:
      raise ValueError('Can not provide both feed_fn and x or y.')

    df = data_feeder.setup_train_data_feeder(x, y, n_classes=None,
                                             batch_size=batch_size,
                                             shuffle=shuffle,
                                             epochs=epochs)
    return df.input_builder, df.get_feed_dict_fn()

  if (x is not None) or (y is not None):
    raise ValueError('Can not provide both input_fn and x or y.')
  if batch_size is not None:
    raise ValueError('Can not provide both input_fn and batch_size.')

  return input_fn, feed_fn
开发者ID:chinnadhurai,项目名称:block_rnn,代码行数:41,代码来源:estimator.py


示例10: _get_input_fn

def _get_input_fn(x, y, batch_size=None):
  df = data_feeder.setup_train_data_feeder(
      x, y, n_classes=None, batch_size=batch_size)
  return df.input_builder, df.get_feed_dict_fn()
开发者ID:Ajaycs99,项目名称:tensorflow,代码行数:4,代码来源:stability_test.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python learn_runner.run函数代码示例发布时间:2022-05-27
下一篇:
Python data_feeder.setup_train_data_feeder函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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