Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

torch_tensor

Converts R objects to a torch tensor


Description

Converts R objects to a torch tensor

Usage

torch_tensor(
  data,
  dtype = NULL,
  device = NULL,
  requires_grad = FALSE,
  pin_memory = FALSE
)

Arguments

data

an R atomic vector, matrix or array

dtype

a torch_dtype instance

device

a device creted with torch_device()

requires_grad

if autograd should record operations on the returned tensor.

pin_memory

If set, returned tensor would be allocated in the pinned memory.

Examples

if (torch_is_installed()) {
torch_tensor(c(1,2,3,4))
torch_tensor(c(1,2,3,4), dtype = torch_int())

}

torch

Tensors and Neural Networks with 'GPU' Acceleration

v0.3.0
MIT + file LICENSE
Authors
Daniel Falbel [aut, cre, cph], Javier Luraschi [aut], Dmitriy Selivanov [ctb], Athos Damiani [ctb], Christophe Regouby [ctb], Krzysztof Joachimiak [ctb], RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.