Skip to content

Error when using a bundled Keras model on POSIT Workbench #71

@andrewbcooper

Description

@andrewbcooper

Hello! Thank yo for this amazing packages! I trained a Keras model on my laptop, bundled it, uploaded it to our POSIT Workbench environment, and then tried to use it for predictions. Unfortunately, I got the error:

Error in if (tensorflow::tf_version() < "2.0.0") stop("TensorFlow version >= 2.0.0 is requires to load models in the SavedModel format.", :
argument is of length zero

My guess it's because we don't actually have TensorFlow installed on the POSIT Workbench servers (e.g., install_tensorflow(); install_keras()) even though we have both TensorFlow and Keras packages installed. tensorflow::tf_version() returns NULL.

Is there any way to use bundle to get predictions from a Keras model without installing TensorFlow / Keras? Our IT folks say it'll probably be 6-9 months before they can get around to that :/

Thanks!

Non-reproducable code:

On my laptop:

bundled_NNModel <-
bundle(NNModel)

save(bundled_NNModel,file="bundled_NNModel.RData")

After uploading to the server....

load("bundled_NNModel.RData")
library(keras)

r(
function(model_bundle, new_data) {
library(bundle)

model_object <- unbundle(model_bundle)

predict(model_object, new_data)

},
args = list(
model_bundle = bundled_NNModel,
new_data = as.matrix(testfeatures)
)
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions