Learn R Programming

vmsae (version 0.1.2)

load_vae: Load Pretrained VAE Decoder

Description

Load a pretrained Variational Autoencoder (VAE) decoder from disk. This function reads the saved PyTorch model weights and corresponding GEOID list, and constructs a Decoder S4 object with the loaded parameters.

Usage

load_vae(model_name, save_dir = NULL)

Value

An object of class Decoder, containing the decoder weights and region identifiers.

Arguments

model_name

Character. The name of the trained VAE model (without .zip extensions).

save_dir

Character. The directory where the trained VAE model is saved. Defaults to the current directory if NULL.

Details

This function assumes the model was trained and saved using train_vae(), and that the decoder weights are stored in a file compatible with torch::load() (via reticulate). It extracts the decoder input/output weights and biases, along with region GEOIDs, and returns them as an S4 object of class Decoder.

Examples

Run this code
if (FALSE) {
library(vmsae)
# this function is time consuming for the first run
install_environment()
load_environment()
decoder <- load_vae(model_name = "mo_county")
}

Run the code above in your browser using DataLab