• Stars
    star
    495
  • Rank 88,974 (Top 2 %)
  • Language
    C++
  • License
    Other
  • Created almost 5 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

R Interface to Torch

torch

Lifecycle: experimental Test CRAN status Discord

Installation

torch can be installed from CRAN with:

install.packages("torch")

You can also install the development version with:

remotes::install_github("mlverse/torch")

At the first package load additional software will be installed. See also the full installation guide here.

Examples

You can create torch tensors from R objects with the torch_tensor function and convert them back to R objects with as_array.

library(torch)
x <- array(runif(8), dim = c(2, 2, 2))
y <- torch_tensor(x, dtype = torch_float64())
y
#> torch_tensor
#> (1,.,.) = 
#>   0.6192  0.5800
#>   0.2488  0.3681
#> 
#> (2,.,.) = 
#>   0.0042  0.9206
#>   0.4388  0.5664
#> [ CPUDoubleType{2,2,2} ]
identical(x, as_array(y))
#> [1] TRUE

Simple Autograd Example

In the following snippet we let torch, using the autograd feature, calculate the derivatives:

x <- torch_tensor(1, requires_grad = TRUE)
w <- torch_tensor(2, requires_grad = TRUE)
b <- torch_tensor(3, requires_grad = TRUE)
y <- w * x + b
y$backward()
x$grad
#> torch_tensor
#>  2
#> [ CPUFloatType{1} ]
w$grad
#> torch_tensor
#>  1
#> [ CPUFloatType{1} ]
b$grad
#> torch_tensor
#>  1
#> [ CPUFloatType{1} ]

Contributing

No matter your current skills it’s possible to contribute to torch development. See the contributing guide for more information.

More Repositories

1

chattr

R
191
star
2

tabnet

An R implementation of TabNet
R
109
star
3

luz

Higher Level API for torch
R
82
star
4

torchvision

R interface to torchvision
R
62
star
5

libtorch-mac-m1

LibTorch builds for the M1 Macs
50
star
6

tok

Tokenizers from HuggingFace
R
40
star
7

tabulate

Pretty Console Output for Tables
C++
39
star
8

cuda.ml

R interface for cuML
R
33
star
9

torchbook_materials

R
28
star
10

torchaudio

R interface to torchaudio
R
26
star
11

tft

R implementation of Temporal Fusion Transformers
R
25
star
12

torch-learnr

Learnr tutorials for Torch
R
19
star
13

minhub

Minimal implementation of Deep Learning models
R
17
star
14

pysparklyr

Extension to {sparklyr} that allows you to interact with Spark & Databricks Connect
R
14
star
15

torchdatasets

Extra datasets for torch
R
14
star
16

hftokenizers

Hugging face tokenizers for R using extendr
Rust
12
star
17

hfhub

Download and cache HuggingFace Hub files
R
11
star
18

tfevents

Write events for TensorBoard
C++
10
star
19

lltm

Long Long Term Memory Neural Net Cells
C++
9
star
20

torchvisionlib

torchvision C++ library extensions
C++
8
star
21

torchsparse

R interface for torchsparse
R
7
star
22

safetensors

Safetensors File Format
R
7
star
23

mall

Run multiple LLM predictions against a data frame with R and Python
R
7
star
24

lantern

C Interface to Torch
C++
5
star
25

madgrad

Madgrad optimizer interface for R
R
5
star
26

callq

Promise Task Queues
R
5
star
27

docker

Docker images for R with GPU support.
Dockerfile
4
star
28

torchwavelets

R
3
star
29

imagenet

Resources to Train ImageNet from R
Dockerfile
3
star
30

package

An R package to easily install all dependencies
R
3
star
31

duktape

R JavaScript interpreter using duktape
C
3
star
32

distributed

Resources to run deep learning with distributed computing
3
star
33

logo

An over-engineered hex logo!
2
star
34

pagedtablejs

JavaScript data table for Data Science
JavaScript
2
star
35

ISLR-deeplearning-torch

Deep Learning lab for the ISLR book.
HTML
2
star
36

libcuml-builds

1
star
37

wav

Read and write WAV files.
C
1
star