Unflattens a tensor dim expanding it to a desired shape. For use with [nn_sequential.
nn_module
Calls torch::nn_unflatten() when trained.
Parameters
dim::integer(1)
The dimension to unflatten. Negative values are interpreted downwards from the last dimension.unflattened_size::integer()
The sizes that replace that dimension. One of them at most can be-1, which torch infers from the size of the dimension being unflattened.
Input and Output Channels
One input channel called "input" and one output channel called "output".
For an explanation see PipeOpTorch.
Super classes
mlr3pipelines::PipeOp -> PipeOpTorch -> PipeOpTorchUnflatten
Methods
PipeOpTorchUnflatten$new()
Creates a new instance of this R6 class.
Usage
PipeOpTorchUnflatten$new(id = "nn_unflatten", param_vals = list())Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that would otherwise be set during construction.
Examples
# Construct the PipeOp
pipeop = nn("unflatten", dim = 2, unflattened_size = c(2, 2))
pipeop
#>
#> ── PipeOp <unflatten>: not trained ─────────────────────────────────────────────
#> Values: dim=2, unflattened_size=2,2
#>
#> ── Input channels:
#> name train predict
#> <char> <char> <char>
#> input ModelDescriptor Task
#>
#> ── Output channels:
#> name train predict
#> <char> <char> <char>
#> output ModelDescriptor Task
# The available parameters
pipeop$param_set
#> <ParamSet(2)>
#> id class lower upper nlevels default value
#> <char> <char> <num> <num> <num> <list> <list>
#> 1: dim ParamInt -Inf Inf Inf <NoDefault[0]> 2
#> 2: unflattened_size ParamUty NA NA Inf <NoDefault[0]> 2,2