Reputation: 171
I haven't been able to save a keras model, I have been using this code:
save_model_hdf5(model, "F:/Models/1")
And I get this error message:
#Error in py_call_impl(callable, dots$args, dots$keywords):
#OSError: Unable to create file(unable to open file: name = 'F:\Modelos\1', error = 13,error message = 'Permission denied', flags = 13,o_flags = 302)
Upvotes: 0
Views: 1653
Reputation: 2370
Python:
I use model.save(filename.hdf5)
to save my models. Note that model
is an object, e.g. created by model.compile(...)
. Find a full example here:
# Set up model
model = models.Sequential()
...
# Compile model
model.compile(...)
...
# Save model
model.save('C:/savepath/savename.hdf5')
It is possible to load the model again, e.g. to make predictions as outlined here.
# Load model
model = load_model('C:/savepath/savename.hdf5')
R:
In R, saving models works a little different:
# Set up a model
model <- create_model()
...
# Fit the model
model %>% fit()
...
# Save the model
model %>% save_model_hdf5("C:/savepath/savename.hdf5")
Or alternatively (without infix operator %>%
which is not part of base R):
save_model_hdf5(model, "C:/savepath/savename.hdf5")
Upvotes: 2