View source: R/gen-namespace.R
torch_repeat_interleave | R Documentation |
Repeat_interleave
torch_repeat_interleave(self, repeats, dim = NULL, output_size = NULL)
self |
(Tensor) the input tensor. |
repeats |
(Tensor or int) The number of repetitions for each element. repeats is broadcasted to fit the shape of the given axis. |
dim |
(int, optional) The dimension along which to repeat values. By default, use the flattened input array, and return a flat output array. |
output_size |
(int, optional) – Total output size for the given axis ( e.g. sum of repeats). If given, it will avoid stream syncronization needed to calculate output shape of the tensor. |
Repeat elements of a tensor.
This is different from `torch_Tensor.repeat` but similar to `numpy.repeat`.
If the repeats
is tensor([n1, n2, n3, ...])
, then the output will be
tensor([0, 0, ..., 1, 1, ..., 2, 2, ..., ...])
where 0
appears n1
times,
1
appears n2
times, 2
appears n3
times, etc.
if (torch_is_installed()) {
## Not run:
x = torch_tensor(c(1, 2, 3))
x$repeat_interleave(2)
y = torch_tensor(matrix(c(1, 2, 3, 4), ncol = 2, byrow=TRUE))
torch_repeat_interleave(y, 2)
torch_repeat_interleave(y, 3, dim=1)
torch_repeat_interleave(y, torch_tensor(c(1, 2)), dim=1)
## End(Not run)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.