Construct an Input Function

This function constructs input function from various types of input used to feed different TensorFlow estimators.

input_fn(object, ...)

# S3 method for default
input_fn(object, ...)

# S3 method for formula
input_fn(object, data, ...)

# S3 method for 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 list
input_fn(object, features, response = NULL, batch_size = 128,
  shuffle = "auto", num_epochs = 1, queue_capacity = 1000,
  num_threads = 1, ...)

# S3 method for matrix
input_fn(object, ...)

Arguments

object, data

An 'input source' -- either a data set (e.g. an R data.frame), or another kind of object that can provide the data required for training.

...

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 "auto" (the default), shuffling will be performed except when this input function is called by a predict() method.

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, num_threads should be 1.

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)
# }
# NOT RUN { # Construct the input function from a data.frame object input_fn1 <- input_fn(mtcars, response = mpg, features = c(drat, cyl)) # }
# 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) # }