tfdeploy (version 0.6.1)

load_savedmodel: Load a SavedModel

Description

Loads a SavedModel using the given TensorFlow session and returns the model's graph.

Usage

load_savedmodel(sess = NULL, model_dir = NULL)

Arguments

sess

The TensorFlow session. NULL if using Eager execution.

model_dir

The path to the exported model, as a string. Defaults to a "savedmodel" path or the latest training run.

Details

Loading a model improves performance over multiple predict_savedmodel() calls.

See Also

export_savedmodel(), predict_savedmodel()

Examples

Run this code
# NOT RUN {
# start session
sess <- tensorflow::tf$Session()

# preload an existing model into a TensorFlow session
graph <- tfdeploy::load_savedmodel(
  sess,
  system.file("models/tensorflow-mnist", package = "tfdeploy")
)

# perform prediction based on a pre-loaded model
tfdeploy::predict_savedmodel(
  list(rep(9, 784)),
  graph
)

# close session
sess$close()
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab