load_shrinkGPR: Load a saved shrinkGPR model object from disk

View source: R/save_load.R

load_shrinkGPRR Documentation

Load a saved shrinkGPR model object from disk

Description

load_shrinkGPR restores a model object previously saved by save_shrinkGPR, reconstructing the trained model, optimizer state, and all metadata. The loaded object can be used directly for prediction or passed as cont_model to continue training.

Usage

load_shrinkGPR(file)

Arguments

file

a character string specifying the file path to load from.

Details

If the model was originally trained on CUDA and CUDA is available on the current machine, the model is loaded on CUDA. Otherwise, it is loaded on CPU with an informative message. The optimizer state (including Adam momentum and adaptive learning rate accumulators) is fully restored, so continued training via cont_model picks up where the original run left off.

Value

An object of the same class as the one that was saved, with the same structure as returned by shrinkGPR, shrinkTPR, shrinkMVGPR, or shrinkMVTPR.

Author(s)

Peter Knaus peter.knaus@wu.ac.at

See Also

save_shrinkGPR

Examples


if (torch::torch_is_installed()) {
  # Fit a model and save it
  sim <- simGPR()
  mod <- shrinkGPR(y ~ ., data = sim$data)
  tmp <- tempfile(fileext = ".zip")
  save_shrinkGPR(mod, tmp)

  # Load and predict
  mod_loaded <- load_shrinkGPR(tmp)
  preds <- predict(mod_loaded, newdata = sim$data[1:10, ])
  }


shrinkGPR documentation built on March 30, 2026, 5:06 p.m.