• Stars
    star
    470
  • Rank 90,272 (Top 2 %)
  • Language
    C++
  • License
    Other
  • Created over 4 years ago
  • Updated 25 days 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
151
star
2

tabnet

An R implementation of TabNet
R
100
star
3

luz

Higher Level API for torch
R
75
star
4

torchvision

R interface to torchvision
R
63
star
5

libtorch-mac-m1

LibTorch builds for the M1 Macs
48
star
6

tabulate

Pretty Console Output for Tables
C++
39
star
7

cuda.ml

R interface for cuML
R
31
star
8

tok

Tokenizers from HuggingFace
R
27
star
9

torchbook_materials

R
27
star
10

torchaudio

R interface to torchaudio
R
26
star
11

tft

R implementation of Temporal Fusion Transformers
R
24
star
12

torch-learnr

Learnr tutorials for Torch
R
18
star
13

minhub

Minimal implementation of Deep Learning models
R
14
star
14

torchdatasets

Extra datasets for torch
R
14
star
15

hftokenizers

Hugging face tokenizers for R using extendr
Rust
12
star
16

pysparklyr

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

hfhub

Download and cache HuggingFace Hub files
R
9
star
18

tfevents

Write events for TensorBoard
C++
9
star
19

lltm

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

torchvisionlib

torchvision C++ library extensions
C++
7
star
21

torchsparse

R interface for torchsparse
R
7
star
22

docker

Docker images to help scale Data Science workflows
Dockerfile
7
star
23

safetensors

Safetensors File Format
R
6
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

torchwavelets

R
3
star
28

imagenet

Resources to Train ImageNet from R
Dockerfile
3
star
29

duktape

R JavaScript interpreter using duktape
C
3
star
30

distributed

Resources to run deep learning with distributed computing
3
star
31

package

An R package to easily install all dependencies
R
2
star
32

pagedtablejs

JavaScript data table for Data Science
JavaScript
2
star
33

ISLR-deeplearning-torch

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

libcuml-builds

1
star
35

logo

An over-engineered hex logo!
1
star
36

wav

Read and write WAV files.
C
1
star