R/save-load.R

Defines functions ctgan_save ctgan_load

Documented in ctgan_load ctgan_save

#' Save a CTGAN model
#'
#' Serialize a CTGAN Model object to disk.
#'
#' @param path Path to which the save the model.
#' @inheritParams ctgan_sample
#' @export
ctgan_save <- function(ctgan_model, path) {
  ctgan_model$save(path)
}

#' Load a saved CTGAN model
#'
#' @param path Path to the saved model.
#' @export
ctgan_load <- function(path) {
  py_obj <- reticulate::py_load_object(file.path(path, "model.pickle"))
  metadata <- readRDS(file.path(path, "metadata.rds"))
  CTGANModel$new(py_obj, metadata)
}
kasaai/ctgan documentation built on Feb. 19, 2020, 8:19 p.m.