Replies: 1 comment
-
|
I suspect something is off with the Python environment, maybe Keras or TensorFlow (or maybe # Run a model.
library(keras)
mnist <- dataset_mnist()
x_train <- mnist$train$x
y_train <- mnist$train$y
x_test <- mnist$test$x
y_test <- mnist$test$y
x_train <- array_reshape(x_train, c(nrow(x_train), 784))
x_test <- array_reshape(x_test, c(nrow(x_test), 784))
x_train <- x_train / 255
x_test <- x_test / 255
y_train <- to_categorical(y_train, 10)
y_test <- to_categorical(y_test, 10)
model <- keras_model_sequential()
model %>%
layer_dense(units = 256, activation = 'relu', input_shape = c(784)) %>%
layer_dropout(rate = 0.4) %>%
layer_dense(units = 128, activation = 'relu') %>%
layer_dropout(rate = 0.3) %>%
layer_dense(units = 10, activation = 'softmax')
model %>% compile(
loss = 'categorical_crossentropy',
optimizer = optimizer_rmsprop(),
metrics = c('accuracy')
)
model %>% fit(
x_train, y_train,
epochs = 30, batch_size = 128,
validation_split = 0.2
)
# Save the model.
tmp <- tempfile()
save_model_hdf5(object = model, filepath = tmp)
# Do you get an error when you read the model?
load_model_hdf5(tmp) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I am learning in chapter 3: Changes to workflow. After sourcing R scripts and
make(plan), everything seems fine. However, when I usereadd(best_model)to see the the output, it returns me an error as bellow:I did not find similar closed issues, so I would like to ask if you can help me with this problem. Many thanks!
Here is my sessionInfo:
Beta Was this translation helpful? Give feedback.
All reactions