ankane / torch.rb

Deep learning for Ruby, powered by LibTorch
Other
704 stars 30 forks source link

Missing `Torch::Generator` #36

Closed c4lliope closed 1 year ago

c4lliope commented 1 year ago

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?

ankane commented 1 year ago

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

c4lliope commented 1 year ago

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.

ankane commented 1 year ago

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