all_dims: All dims

Description Usage Examples

View source: R/extract.R

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). In Python, if x is a numpy array or a torch tensor, in 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].

Usage

1

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## 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]

## End(Not run)

rTorch documentation built on Jan. 13, 2021, 4:32 p.m.