Learn R Programming

rTorch (version 0.0.3)

all_dims: All dims

Description

This function returns an object that can be used when subsetting tensors with `[`. If you are familiar with Python, this is equivalent to the Python Ellipsis `...`, (not to be confused with `...` in `R`).

Usage

all_dims()

Arguments

Examples

Run this code
# NOT RUN {
# in python, if x is a numpy array or torch tensor
x[..., i]
# the ellipsis means "expand to match number of dimension of x".
# to translate the above python expression to R, write:
x[all_dims(), i]
# }
# NOT RUN {
# Run this
d <- torch$tensor(list(list(0, 0),
                       list(0, 0),
                       list(0, 1),
                       list(1, 1)), dtype=torch$uint8)
d[all_dims(), 1]

f <- torch$arange(9L)$reshape(c(3L, 3L))
f
f[all_dims()]
f[all_dims(), 1L]
# }

Run the code above in your browser using DataLab