Load a SavedModel

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

load_savedmodel(sess, model_dir = NULL)

Arguments

sess

The TensorFlow session.

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

# 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()
# }