Creates a torch tensor.
tensor(x, ...)
x | an R object or a torch tensor. |
---|---|
dtype | the desired data type of returned tensor. Default: if |
device | the desired device of returned tensor. Default: if |
requires_grad | If autograd should record operations on the
returned tensor. Default: |
x <- tensor(1:10) x#> tensor #> 1 #> 2 #> 3 #> 4 #> 5 #> 6 #> 7 #> 8 #> 9 #> 10 #> [ Variable[CPUIntType]{10} ]y <- tensor(x, dtype = "double") y#> tensor #> 1 #> 2 #> 3 #> 4 #> 5 #> 6 #> 7 #> 8 #> 9 #> 10 #> [ Variable[CPUDoubleType]{10} ]