Skip to contents

Clones a module.

Usage

clone_module(module, deep = FALSE, ..., replace_values = TRUE)

Arguments

module

(nn_module)
The module to clone

deep

(logical(1))
Whether to create a deep clone.

...

(any)
Additional parameters, currently unused.

replace_values

(logical(1))
Whether to replace parameters and buffers with the cloned values.

Examples

if (torch_is_installed()) {
clone_module(nn_linear(1, 1), deep = TRUE)
# is the same as
nn_linear(1, 1)$clone(deep = TRUE)
}
#> An `nn_module` containing 2 parameters.
#> 
#> ── Parameters ──────────────────────────────────────────────────────────────────
#> • weight: Float [1:1, 1:1]
#> • bias: Float [1:1]