1
$\begingroup$

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!

$\endgroup$

1 Answer 1

1
$\begingroup$

Why losses are so big?

It seems that the model you specified isn't very good. It could mean that these features aren't good predictors. It could mean that the neural network could be improved in some way. Setting up a good neural network is a task-specific problem that usually involves some trial-and-error. See: What should I do when my neural network doesn't learn?

What does label/mean and preddiction/mean mean?

I'd consult the documentation or ask the maintainer of the package/software.

What is the difference between steps and epochs?

Most neural networks don't use all of the data at once. Instead, at each step, a small sample of the data are used to update model parameters. An epoch is comprised of steps, so that each sample is used exactly once in each epoch.

$\endgroup$
1
  • 1
    $\begingroup$ Thanks Sycorax, with proper features the loss is much better. $\endgroup$ Commented May 5, 2019 at 3:57

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.