nn_unflatten: Unflattens a tensor dim expanding it to a desired shape. For...

nn_unflattenR Documentation

Unflattens a tensor dim expanding it to a desired shape. For use with [nn_sequential.

Description

Unflattens a tensor dim expanding it to a desired shape. For use with [nn_sequential.

Usage

nn_unflatten(dim, unflattened_size)

Arguments

dim

Dimension to be unflattened

unflattened_size

New shape of the unflattened dimension

Examples

if (torch_is_installed()) {
input <- torch_randn(2, 50)

m <- nn_sequential(
  nn_linear(50, 50),
  nn_unflatten(2, c(2, 5, 5))
)
output <- m(input)
output$size()
}

torch documentation built on May 29, 2024, 9:54 a.m.