| load_shrinkGPR | R Documentation |
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.
load_shrinkGPR(file)
file |
a character string specifying the file path to load from. |
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.
An object of the same class as the one that was saved, with the same
structure as returned by shrinkGPR, shrinkTPR, shrinkMVGPR,
or shrinkMVTPR.
Peter Knaus peter.knaus@wu.ac.at
save_shrinkGPR
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, ])
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.