I try the code at tensorflow in R tutorial (https://tensorflow.rstudio.com/tfestimators/) but I cannot understand the output what the code produces.
Code:
library(tfestimators)
install_tensorflow()
# return an input_fn for a given subset of data
mtcars_input_fn <- function(data, num_epochs = 1) {
input_fn(data,
features = c("disp", "cyl"),
response = "mpg",
batch_size = 32,
num_epochs = num_epochs)
}
cols <- feature_columns(
column_numeric("disp", "cyl")
)
model <- linear_regressor(feature_columns = cols)
indices <- sample(1:nrow(mtcars), size = 0.80 * nrow(mtcars))
train <- mtcars[indices, ]
test <- mtcars[-indices, ]
# train the model
model %>% train(mtcars_input_fn(train, num_epochs = 10))
model %>% evaluate(mtcars_input_fn(test))
Train function output:
[/] Training -- loss: 6459.84, step: 8
Evaluate function output:
`label/mean` average_loss global_step `prediction/mean` loss
<dbl> <dbl> <dbl> <dbl> <dbl>
1 21.6 177. 8 11.6 1239.
My questions:
- Why losses are so big?
- What does label/mean and preddiction/mean mean?
- What is the difference between steps and epochs?
Thanks!