Returns a tensor of given size filled with fill_value.

tch_full(size, fill_value, dtype = NULL, layout = NULL,
  device = NULL, requires_grad = FALSE)

Arguments

size

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

fill_value

the number to fill the output tensor with.

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.

the

desired layout of returned Tensor. Default: 'strided'

Examples

tch_full(c(2, 3), 3.141592)
#> tensor #> 3.1416 3.1416 3.1416 #> 3.1416 3.1416 3.1416 #> [ Variable[CPUFloatType]{2,3} ]
tch_full(c(2, 3, 4), 0)
#> tensor #> (1,.,.) = #> 0 0 0 0 #> 0 0 0 0 #> 0 0 0 0 #> #> (2,.,.) = #> 0 0 0 0 #> 0 0 0 0 #> 0 0 0 0 #> [ Variable[CPUFloatType]{2,3,4} ]