| get_py_MAF_handle | R Documentation |
Utility initializing a Python environment for running zuko.flows.MAF and retrieving it.
get_py_MAF_handle(envir, reset=FALSE, torch_device="cpu", GPU_mem=NULL,
verbose = TRUE)
envir |
An environment (in the R sense) initialized as shown in the Examples. |
reset |
Boolean: Whether to reinitialize the Python session or not. |
torch_device |
Character: |
GPU_mem |
For development purposes (effect is complicated). An amount of (dedicated) GPU memory, in bytes. |
verbose |
Boolean. Whether to print some messages or not. |
If successful, get_py_MAF_handle returns the modified input environment.
If sourcing the Python code provided by mafR failed (presumably from trying to use an improperly set-up Python environment), the error condition message is returned.
init_py_env, control_py_env
## Not run: # too slow for CRAN checks
# Initialization of python virtual environment:
init_py_env(test_cuda=FALSE)
# Initialization of python session (defines functions etc.
# in python session and provide access to them from R):
#
my_env <- list2env(list(is_set=FALSE),parent = emptyenv())
py_handle <- get_py_MAF_handle(my_env, reset=FALSE, torch_device="cpu")
# => get_py_MAF_handle() has added objects in myenv:
my_env$torch # Imported Python package (result of reticulate::import("torch"))
my_env$device # the torch_device
# and functions for MAF training, such as myenv$MAF_density_estimation.
# The returned 'py_handle' can be used by oher functions, e.g.:
control_py_env(py_handle, seed=0L)
# alters the seed in the python session.
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.