torch_randint {torch} | R Documentation |
Randint
Description
Randint
Usage
torch_randint(
low,
high,
size,
generator = NULL,
dtype = NULL,
layout = NULL,
device = NULL,
requires_grad = FALSE,
memory_format = torch_preserve_format()
)
Arguments
low |
(int, optional) Lowest integer to be drawn from the distribution. Default: 0. |
high |
(int) One above the highest integer to be drawn from the distribution. |
size |
(tuple) a tuple defining the shape of the output tensor. |
generator |
( |
dtype |
( |
layout |
( |
device |
( |
requires_grad |
(bool, optional) If autograd should record operations on the returned tensor. Default: |
memory_format |
memory format for the resulting tensor. |
randint(low=0, high, size, *, generator=NULL, out=NULL, \
dtype=NULL, layout=torch.strided, device=NULL, requires_grad=False) -> Tensor
Returns a tensor filled with random integers generated uniformly
between low
(inclusive) and high
(exclusive).
The shape of the tensor is defined by the variable argument size
.
.. note:
With the global dtype default (torch_float32
), this function returns
a tensor with dtype torch_int64
.
Examples
if (torch_is_installed()) {
torch_randint(3, 5, list(3))
torch_randint(0, 10, size = list(2, 2))
torch_randint(3, 10, list(2, 2))
}