Open ghost opened 4 years ago
I've had similar issues. I guess the culprit is "normalizer_fn = scaler_standard()"
it returns NaN on the trianing set after running:
train_dataset %>% reticulate::as_iterator() %>% reticulate::iter_next() %>% layer()
Even when removing "normalizer_fn = scaler_standard()" I am still getting the error. However, when running the network
input <- layer_input_from_dataset(train_df %>% select(-label))
output <- input %>%
layer_dense_features(dense_features(spec)) %>%
layer_dense(units = 64, activation = "relu") %>%
layer_dense(units = 64, activation = "relu") %>%
layer_dense(units = 1)
model <- keras_model(input, output)
model %>%
compile(
loss = "mse",
optimizer = optimizer_rmsprop(),
metrics = list("mean_absolute_error")
)
# Display training progress by printing a single dot for each completed epoch.
print_dot_callback <- callback_lambda(
on_epoch_end = function(epoch, logs) {
if (epoch %% 80 == 0) cat("\n")
cat(".")
}
)
history <- model %>% fit(
x = train_df %>% select(-label),
y = train_df$label,
epochs = 500,
validation_split = 0.2,
verbose = 0,
view_metrics = TRUE,
callbacks = list(print_dot_callback, callback_early_stopping(monitor = "val_loss", patience = 5, restore_best_weights = TRUE))
)
everything works fine and I think even the scaling works, because if I delete the scaler from spec
the NN has a way harder time converging.
So I think, the exception is just caused by calling layer(train_df)
and nothing else is impacted by the error above.
However, it has been more than 2 years since this problem popped up, is there a known solution as to why an error is thrown when calling layer(train_df)
while everything else seems to work just fine?
Feature columns have been deprecated upstream, so this is unlikely to be fixed in the R interface (though I would merge a simple PR).
Doing any kind of stateful feature preprocessing is best done with Keras preprocessing layers these days: https://keras.rstudio.com/articles/new-guides/preprocessing_layers.html
I am doing deep learning using Keras in Rstudio.I copy and paste this link https://tensorflow.rstudio.com/tutorials/beginners/basic-ml/tutorial_basic_regression/