{"id":21428305,"url":"https://github.com/mlverse/torch","last_synced_at":"2025-10-17T00:19:07.264Z","repository":{"id":37962586,"uuid":"232347878","full_name":"mlverse/torch","owner":"mlverse","description":"R Interface to Torch","archived":false,"fork":false,"pushed_at":"2025-04-08T13:51:54.000Z","size":143538,"stargazers_count":525,"open_issues_count":114,"forks_count":79,"subscribers_count":18,"default_branch":"main","last_synced_at":"2025-04-13T06:14:57.424Z","etag":null,"topics":["autograd","deep-learning","r","torch"],"latest_commit_sha":null,"homepage":"https://torch.mlverse.org","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mlverse.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-07T14:56:32.000Z","updated_at":"2025-04-11T15:37:36.000Z","dependencies_parsed_at":"2023-02-19T12:01:12.665Z","dependency_job_id":"44d1ac96-5f7e-4158-950b-672c631b5a9d","html_url":"https://github.com/mlverse/torch","commit_stats":{"total_commits":3774,"total_committers":44,"mean_commits":85.77272727272727,"dds":"0.21436142024377314","last_synced_commit":"9da75b29ac4a2430c5c91690a77eefaf0e6f5c71"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlverse%2Ftorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlverse%2Ftorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlverse%2Ftorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlverse%2Ftorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mlverse","download_url":"https://codeload.github.com/mlverse/torch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670434,"owners_count":21142904,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autograd","deep-learning","r","torch"],"created_at":"2024-11-22T22:12:37.470Z","updated_at":"2025-10-17T00:19:02.238Z","avatar_url":"https://github.com/mlverse.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n \n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r setup, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\ntorch::torch_manual_seed(1)\n```\n\n# torch \u003ca href='https://torch.mlverse.org'\u003e\u003cimg src='man/figures/torch.png' align=\"right\" height=\"139\" /\u003e\u003c/a\u003e\n\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html)\n[![Test](https://github.com/mlverse/torch/actions/workflows/main.yaml/badge.svg)](https://github.com/mlverse/torch/actions/workflows/main.yaml)\n[![CRAN status](https://www.r-pkg.org/badges/version/torch)](https://CRAN.R-project.org/package=torch)\n[![](https://cranlogs.r-pkg.org/badges/torch)](https://cran.r-project.org/package=torch)\n[![Discord](https://img.shields.io/discord/837019024499277855?logo=discord)](https://discord.com/invite/s3D5cKhBkx)\n\n\n## Installation\n\ntorch can be installed from CRAN with:\n\n```r\ninstall.packages(\"torch\")\n```\n\nYou can also install the development version with:\n\n```r\nremotes::install_github(\"mlverse/torch\")\n```\n\nAt the first package load additional software will be \ninstalled. See also the full [installation guide](https://torch.mlverse.org/docs/articles/installation.html) here.\n\n## Examples\n\nYou can create torch tensors from R objects with the `torch_tensor` function and convert them back to R objects with `as_array`.\n\n```{r}\nlibrary(torch)\nx \u003c- array(runif(8), dim = c(2, 2, 2))\ny \u003c- torch_tensor(x, dtype = torch_float64())\ny\nidentical(x, as_array(y))\n```\n\n### Simple Autograd Example\n\nIn the following snippet we let torch, using the autograd feature, calculate the derivatives:\n\n```{r}\nx \u003c- torch_tensor(1, requires_grad = TRUE)\nw \u003c- torch_tensor(2, requires_grad = TRUE)\nb \u003c- torch_tensor(3, requires_grad = TRUE)\ny \u003c- w * x + b\ny$backward()\nx$grad\nw$grad\nb$grad\n```\n\n## Contributing\n\nNo matter your current skills it's possible to contribute to `torch` development.\nSee the [contributing guide](https://torch.mlverse.org/docs/contributing) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlverse%2Ftorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmlverse%2Ftorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlverse%2Ftorch/lists"}