ankane / torch.rb

Deep learning for Ruby, powered by LibTorch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing `Torch::Generator`

c4lliope opened this issue · comments

In PyTorch I can use a random generator, such as:

g = torch.Generator().manual_seed(2147483647)
p = Torch.tensor([0.2, 0.6, 0.2])
ix = torch.multinomial(p, num_samples=1, replacement=True,generator=g).item()

Is there a recommended approach for using the generator, including methods like multinomial?

Hey @c4lliope, thanks for reporting! Added in the commit above (note that p must be a tensor in the latest PyTorch).

Amazingly quick response! In all my years of open-source,
I really need to praise your upkeep here.
I hope you keep making this essential library accessible in Ruby,
so machine learning can be approached easily by more people.

No problem. Let me know if you run into anything else that's missing.