Skip to content

Commit

Permalink
Doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mingdeyu committed Dec 12, 2024
1 parent 5e2b7ad commit 98e6f84
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 32 deletions.
34 changes: 17 additions & 17 deletions R/serialization.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#'
#' `r new_badge("new")`
#'
#' This function serialize the constructed emulator.
#' This function serializes the constructed emulator.
#'
#' @param object an instance of the S3 class `gp`, `dgp`, `lgp`, or `bundle`.
#' @param light a bool indicating if a light version of the constructed emulator (that requires a small storage) will be serialized.
Expand All @@ -23,34 +23,34 @@
#' library(future.apply)
#' library(dgpsi)
#'
#' # Model
#' # model
#' f <- function(x) {
#' (sin(7.5*x)+1)/2
#' }
#'
#' # Training data
#' # training data
#' X <- seq(0, 1, length = 10)
#' Y <- sapply(X, f)
#'
#' # Training a DGP emulator
#' # train a DGP emulator
#' m <- dgp(X, Y, name = "matern2.5")
#'
# Testing input data
#' # testing input data
#' X_dgp <- seq(0, 1, length = 100)
#'
#' # Serialize the DGP emulator
#' # serialize the DGP emulator
#' m_serialized <- serialize(m)
#'
#' # Start a multi-session with three cores for parallel predictions
#' # start a multi-session with three cores for parallel predictions
#' plan(multisession, workers = 3)
#'
#' # Perform parallel predictions
#' # perform parallel predictions
#' results <- future_lapply(1:length(X_dgp), function(i) {
#' m_deserialized <- deserialize(m_serialized)
#' mean_i <- predict(m_deserialized, X_dgp[i])$results$mean
#' }, future.seed = TRUE)
#'
#' # Reset the future plan to sequential
#' # reset the future plan to sequential
#' plan(sequential)
#'
#' # combine mean predictions
Expand Down Expand Up @@ -120,34 +120,34 @@ serialize <- function(object, light = TRUE) {
#' library(future.apply)
#' library(dgpsi)
#'
#' # Model
#' # model
#' f <- function(x) {
#' (sin(7.5*x)+1)/2
#' }
#'
#' # Training data
#' # training data
#' X <- seq(0, 1, length = 10)
#' Y <- sapply(X, f)
#'
#' # Training a DGP emulator
#' # train a DGP emulator
#' m <- dgp(X, Y, name = "matern2.5")
#'
# Testing input data
#' # testing input data
#' X_dgp <- seq(0, 1, length = 100)
#'
#' # Serialize the DGP emulator
#' # serialize the DGP emulator
#' m_serialized <- serialize(m)
#'
#' # Start a multi-session with three cores for parallel predictions
#' # start a multi-session with three cores for parallel predictions
#' plan(multisession, workers = 3)
#'
#' # Perform parallel predictions
#' # perform parallel predictions
#' results <- future_lapply(1:length(X_dgp), function(i) {
#' m_deserialized <- deserialize(m_serialized)
#' mean_i <- predict(m_deserialized, X_dgp[i])$results$mean
#' }, future.seed = TRUE)
#'
#' # Reset the future plan to sequential
#' # reset the future plan to sequential
#' plan(sequential)
#'
#' # combine mean predictions
Expand Down
15 changes: 8 additions & 7 deletions man/deserialize.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions man/serialize.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 98e6f84

Please sign in to comment.