Returns a tensor filled with random integers generated uniformly between low (inclusive) and high (exclusive).

tch_randint(low = 0, high = NULL, sizes = NULL, dtype = NULL,
  layout = NULL, device = NULL, requires_grad = FALSE)

Arguments

low

(optional) Lowest integer to be drawn from the distribution. Default: 0.

sizes

a sequence of integers defining the shape of the output tensor.

dtype

the desired data type of returned tensor. Default: if NULL, infers data type from x.

device

the desired device of returned tensor. Default: if NULL, uses the current device for the default tensor type (see tch_set_default_tensor_type()). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

requires_grad

If autograd should record operations on the returned tensor. Default: FALSE.

hogh

One above the highest integer to be drawn from the distribution.

the

desired layout of returned Tensor. Default: 'strided'

Details

The shape of the tensor is defined by the variable argument size.

Examples

tch_randint(3, 5, 3)
#> tensor #> 4 #> 4 #> 3 #> [ Variable[CPUFloatType]{3} ]
tch_randint(10, c(2, 2))
#> tensor #> 5 1 #> 6 1 #> [ Variable[CPUFloatType]{2,2} ]
tch_randint(3, 10, c(2, 2))
#> tensor #> 3 3 #> 3 9 #> [ Variable[CPUFloatType]{2,2} ]