Learn R Programming

torch (version 0.0.1)

torch_flatten: Flatten

Description

Flatten

Arguments

input

(Tensor) the input tensor.

start_dim

(int) the first dim to flatten

end_dim

(int) the last dim to flatten

flatten(input, start_dim=0, end_dim=-1) -> Tensor

Flattens a contiguous range of dims in a tensor.

Examples

Run this code
# NOT RUN {
if (torch_is_installed()) {

t = torch_tensor(matrix(c(1, 2), ncol = 2))
torch_flatten(t)
torch_flatten(t, start_dim=2)
}
# }

Run the code above in your browser using DataLab