torch_narrow | R Documentation |
Narrow
torch_narrow(self, dim, start, length)
self |
(Tensor) the tensor to narrow |
dim |
(int) the dimension along which to narrow |
start |
(int) the starting dimension |
length |
(int) the distance to the ending dimension |
Returns a new tensor that is a narrowed version of input
tensor. The
dimension dim
is input from start
to start + length
. The
returned tensor and input
tensor share the same underlying storage.
if (torch_is_installed()) {
x = torch_tensor(matrix(c(1:9), ncol = 3, byrow= TRUE))
torch_narrow(x, 1, 1, 2)
torch_narrow(x, 2, 2, 2)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.