input_fn {tfestimators} | R Documentation |
Construct an Input Function
Description
This function constructs input function from various types of input used to feed different TensorFlow estimators.
Usage
input_fn(object, ...)
## Default S3 method:
input_fn(object, ...)
## S3 method for class 'formula'
input_fn(object, data, ...)
## S3 method for class 'data.frame'
input_fn(
object,
features,
response = NULL,
batch_size = 128,
shuffle = "auto",
num_epochs = 1,
queue_capacity = 1000,
num_threads = 1,
...
)
## S3 method for class 'list'
input_fn(
object,
features,
response = NULL,
batch_size = 128,
shuffle = "auto",
num_epochs = 1,
queue_capacity = 1000,
num_threads = 1,
...
)
## S3 method for class 'matrix'
input_fn(object, ...)
Arguments
object , data |
An 'input source' – either a data set (e.g. an R |
... |
Optional arguments passed on to implementing submethods. |
features |
The names of feature variables to be used. |
response |
The name of the response variable. |
batch_size |
The batch size. |
shuffle |
Whether to shuffle the queue. When |
num_epochs |
The number of epochs to iterate over data. |
queue_capacity |
The size of queue to accumulate. |
num_threads |
The number of threads used for reading and enqueueing. In
order to have predictable and repeatable order of reading and enqueueing,
such as in prediction and evaluation mode, |
Details
For list objects, this method is particularly useful when constructing dynamic length of inputs for models like recurrent neural networks. Note that some arguments are not available yet for input_fn applied to list objects. See S3 method signatures below for more details.
See Also
Other input functions:
numpy_input_fn()
Examples
## Not run:
# Construct the input function through formula interface
input_fn1 <- input_fn(mpg ~ drat + cyl, mtcars)
## End(Not run)
## Not run:
# Construct the input function from a data.frame object
input_fn1 <- input_fn(mtcars, response = mpg, features = c(drat, cyl))
## End(Not run)
## Not run:
# Construct the input function from a list object
input_fn1 <- input_fn(
object = list(
feature1 = list(
list(list(1), list(2), list(3)),
list(list(4), list(5), list(6))),
feature2 = list(
list(list(7), list(8), list(9)),
list(list(10), list(11), list(12))),
response = list(
list(1, 2, 3), list(4, 5, 6))),
features = c("feature1", "feature2"),
response = "response",
batch_size = 10L)
## End(Not run)