Ruby library, powered by LibTorch

Hi, I wanted to let the community know that there are now Ruby bindings for LibTorch. Here’s a short example:

x = Torch.ones(2, 2, requires_grad: true)
y = x + 2
z = y * y * 3
out = z.mean
p x.grad

If you have any feedback, feel free to create an issue in the project for it. Thanks!


Thanks for sharing!
May I ask you, what you are using it for and which use cases are now enabled by Ruby? :slight_smile:

Good questions. I created it as part of a larger effort to improve machine learning in Ruby and am planning to try it for collaborative filtering. It currently supports most of the features of these two tutorials (PyTorch intro and torch.nn intro).