← all repositories
mlverse/torch

PyTorch tensors and autograd, wrapped for R

It exposes PyTorch-style tensors and automatic differentiation directly to R, letting data scientists keep their workflow in one language.

567 stars C++ ML Frameworks
torch
Not currently ranked — collecting fresh signals.
star history

What it does torch bridges R arrays and the Torch C++ backend, letting you create tensors, run math on them, and compute gradients via autograd. The README shows round-tripping data between R arrays and torch_tensor objects, plus a minimal autograd example where derivatives are calculated automatically. It is distributed through CRAN and handles its own binary dependencies.

The interesting bit The package auto-installs its underlying C++ libraries on first load, which is either convenient magic or slightly unnerving infrastructure, depending on your tolerance for post-install surprises. It also wears an “experimental” lifecycle badge while sitting on CRAN—a combination that suggests the maintainers are optimistic and the API is still settling.

Key highlights

  • Tensors convert cleanly to and from R arrays using torch_tensor and as_array.
  • Autograd is fully exposed: define a computation, call $backward(), and read gradients off leaf tensors.
  • CUDA 12.6–12.9 support is advertised via badge, though the README only demonstrates CPU workflows.
  • Distributed on CRAN with CI testing via GitHub Actions.

Caveats

  • The lifecycle badge marks it as experimental, so breaking changes are likely.
  • Additional software is downloaded and installed when the package is first loaded, which could complicate air-gapped or locked-down environments.
  • The README examples stop at basic tensor math and scalar autograd; it is unclear how much of the broader PyTorch ecosystem (modules, optimizers, data loaders) is currently accessible.

Verdict Worth a look if you do deep learning in R and want Torch-style tensors rather than a Python interop layer. Skip it if you need a mature, fully-documented high-level API today.

Frequently asked

What is mlverse/torch?
It exposes PyTorch-style tensors and automatic differentiation directly to R, letting data scientists keep their workflow in one language.
Is torch open source?
Yes — mlverse/torch is an open-source project tracked on heatdrop.
What language is torch written in?
mlverse/torch is primarily written in C++.
How popular is torch?
mlverse/torch has 567 stars on GitHub.
Where can I find torch?
mlverse/torch is on GitHub at https://github.com/mlverse/torch.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.