tf.estimator.inputs.numpy_input_fn

tf.estimator.inputs.numpy_input_fn

tf.estimator.inputs.numpy_input_fn

numpy_input_fn(
    x,
    y=None,
    batch_size=128,
    num_epochs=1,
    shuffle=None,
    queue_capacity=1000,
    num_threads=1
)

Defined in tensorflow/python/estimator/inputs/numpy_io.py.

Returns input function that would feed dict of numpy arrays into the model.

This returns a function outputting features and target based on the dict of numpy arrays. The dict features has the same keys as the x.

Example:

age = np.arange(4) * 1.0
height = np.arange(32, 36)
x = {'age': age, 'height': height}
y = np.arange(-32, -28)

with tf.Session() as session:
  input_fn = numpy_io.numpy_input_fn(
      x, y, batch_size=2, shuffle=False, num_epochs=1)

Args:

  • x: dict of numpy array object.
  • y: numpy array object. None if absent.
  • batch_size: Integer, size of batches to return.
  • num_epochs: Integer, number of epochs to iterate over data. If None will run forever.
  • shuffle: Boolean, if True shuffles the queue. Avoid shuffle at prediction time.
  • queue_capacity: Integer, size of queue to accumulate.
  • num_threads: Integer, number of threads used for reading and enqueueing. In order to have predicted and repeatable order of reading and enqueueing, such as in prediction and evaluation mode, num_threads should be 1.

Returns:

Function, that has signature of ()->(dict of features, target)

Raises:

  • ValueError: if the shape of y mismatches the shape of values in x (i.e., values in x have same shape).
  • TypeError: x is not a dict or shuffle is not bool.

© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/estimator/inputs/numpy_input_fn

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部