Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

R Interface to Torch

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
NotificationsYou must be signed in to change notification settings

mlverse/torch

Repository files navigation

Lifecycle: experimentalTestCRAN statuscudaDiscord

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. Seealso the fullinstallationguide here.

Examples

You can create torch tensors from R objects with thetorch_tensorfunction and convert them back to R objects withas_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+by$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 totorchdevelopment. See thecontributingguide for moreinformation.

About

R Interface to Torch

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Contributing

Stars

Watchers

Forks

Contributors45


[8]ページ先頭

©2009-2025 Movatter.jp