-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
torch_manual_seed does not seem to work with $sample() #937
Comments
I should maybe add that I use torch version 0.9.0 (newest), R version 4.2.0 (2022-04-22), and I run on a mac with operating system x86_64-apple-darwin17.0. Manually setting the seed works for e.g. distr_categorical. library(torch)
dc = distr_categorical(torch_tensor(c(0.1, 0.5, 0.4)))
# Produce the same values
torch_manual_seed(1)
dc$sample(10)
torch_manual_seed(1)
dc$sample(10)
´´´ |
Merged
LHBO
added a commit
to LHBO/shapr
that referenced
this issue
Aug 25, 2023
… to them (mlverse/torch#937). Also added check which removes the timing if it is not desired by the user. I did this mainly because of the test functions in the previous commits. They would fail due to the times beeing different each time they ran this function.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
This is my first time writing on GitHub, so I am unsure if I have included everything you need.
I have a question regarding reproducibility when generating random numbers from distributions.
From pages 36 and 37 in the manual (https://cran.r-project.org/web/packages/torch/torch.pdf) it seems that I should use the $sample() function, but then I am not able to set the seed and reproduce the sampled values even when setting the seed.
However, setting the seed works when I use $rsample(). Is there a particular reason for this?
P.S. I think you have done a splendid job in making torch much more available for us R users!
The text was updated successfully, but these errors were encountered: