Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Deep learning for Ruby, powered by LibTorch
| Date | Stars |
|---|---|
| 2026-07-31 | 836 |
| 2026-08-03 | 836 |
| 2026-08-06 | 836 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# Torch.rb :fire: Deep learning for Ruby, powered by [LibTorch](https://pytorch.org) Also check out: - [TorchVision](https://github.com/ankane/torchvision-ruby) for computer vision tasks - [TorchText](https://github.com/ankane/torchtext-ruby) for text and NLP tasks - [TorchAudio](https://github.com/ankane/torchaudio-ruby) for audio tasks - [TorchCodec](https://github.com/ankane/torchcodec-ruby) for audio and video encoding - [TorchRec](https://github.com/ankane/torchrec-ruby) for recommendation systems - [TorchData](https://github.com/ankane/torchdata-ruby) for data loading As well as: - [Transformers](https://github.com/ankane/transformers-ruby) for transformers - [Safetensors](https://github.com/ankane/safetensors-ruby) for storing tensors [](https://github.com/ankane/torch.rb/actions) ## Installation First, [download LibTorch](https://pytorch.org/get-started/locally/). For Mac arm64, use: ```sh curl -L https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.13.0.zip > libtorch.zip unzip -q libtorch.zip ``` For Linux x86-64, use the build that matches your CUDA version. For other platforms, build LibTorch from source. Then run: ```sh bundle config set build.torch-rb --with-torch-dir=/path/to/libtorch ``` And add this line to your application’s Gemfile: ```ruby gem "torch-rb" ``` It can take 5-10 minutes to compile the extension. Windows is not currently supported. ## Getting Started A good place to start is [Deep Learning with Torch.rb: A 60 Minute Blitz](tutorials/blitz/README.md). ## Tutorials - [Transfer learning](tutorials/transfer_learning/README.md) - [Sequence models](tutorials/nlp/sequence_models.md) - [Word embeddings](tutorials/nlp/word_embeddings.md) ## Examples - [Image classification with MNIST](examples/mnist) ([日本語版](https://qiita.com/kojix2/items/c19c36dc1bf73ea93409)) - [Collaborative filtering with MovieLens](examples/movielens) - [Generative adversarial networks](examples/gan) ## API This library follows the [PyTorch API](https://pytorch.org/docs/stable/torch.html). There are a few changes to make it more Ruby-like: - Methods that perform in-place modifications end with `!` instead of `_` (`add!` instead of `add_`) - Methods that return booleans use `?` instead of `is_` (`tensor?` instead of `is_tensor`) - Numo is used instead of NumPy (`x.numo` instead of `x.numpy()`) You can follow PyTorch tutorials and convert the code to Ruby in many cases. Feel free to open an issue if you run into problems. ## Overview Some examples below are from [Deep Learning with PyTorch: A 60 Minutes Blitz](https://pytorch.org/tutorials/beginner/deep_learning_60min_blitz.html) ### Tensors Create a tensor from a Ruby array ```ruby x = Torch.tensor([[1, 2, 3], [4, 5, 6]]) ``` Get the shape of a tensor ```ruby x.shape ``` There are [many functions](#tensor-creation) to create tensors, like ```ruby a = Torch.rand(3) b = Torch.zeros(2, 3) ``` Each tensor has four properties - `dtype` - the data type - `:uint8`, `:int8`, `:int16`, `:int32`, `:int64`, `:float32`, `:float64`, or `:bool` - `layout` - `:strided` (dense) or `:sparse` - `device` - the compute device, like CPU or GPU - `requires_grad` - whether or not to record gradients You can specify properties when creating a tensor ```ruby Torch.rand(2, 3, dtype: :float64, layout: :strided, device: "cpu", requires_grad: true) ``` ### Operations Create a tensor ```ruby x = Torch.tensor([10, 20, 30]) ``` Add ```ruby x + 5 # tensor([15, 25, 35]) ``` Subtract ```ruby x - 5 # tensor([5, 15, 25]) ``` Multiply ```ruby x * 5 # tensor([50, 100, 150]) ``` Divide ```ruby x / 5 # tensor([2, 4, 6]) ``` Get the remainder ```ruby x % 3 # tensor([1, 2, 0]) ``` Raise to a power ```ruby x**2 # tensor([100, 400, 900]) ``` Perform operations with other tensors ```ruby y = Torch.tensor([1, 2, 3]) x + y # tensor([11, 22, 33]) ``` Perform operations in-plac
Excerpt of 10,945 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:934f6d80d63d9ca5, llm:Description: 'Deep learning for Ruby, powered by LibTorch' (repository description)
matched fp:934f6d80d63d9ca5, llm:Description: 'Deep learning for Ruby, powered by LibTorch' (repository description)