Predict with keras models in R does not work on shinyapps.io

In my Shiny app, I have a serialized keras model that I load with load_model_hdf5() . Then, I give it some data to make predictions for: my_model %>% predict(new_data) . It works perfectly locally, but when I try to deploy it on shinyapps.io, the app crashes with the following error:

no applicable method for 'predict' applied to an object of class
"c('tensorflow.python.keras.engine.sequential.Sequential', 
'tensorflow.python.keras.engine.training.Model', 
'tensorflow.python.keras.engine.network.Network',
 'tensorflow.python.keras.engine.base_layer.Layer', 
'tensorflow.python.module.module.Module',
'tensorflow.python.training.tracking.tracking.AutoTrackable', 
'tensorflow.python.training.tracking.base.Trackable', 
'python.builtin.object')"

This is indeed the list of classes that a keras R model has. Using methods() on all these classes shows that the training.Model one has a predict method.

The app used to work a few months ago, but now I have updated keras and tensorflow to the most recent versions (tf 2.0). Could this be the reason why it does not work at shinyapps.io? If not, what could be the reason?

What versions of the keras and tensorflow R packages are you using (output of rsconnect::appDependencies())?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.