Skip to content
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

Added a '-seed' option to sample.lua to allow for an identical rerun.… #219

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

turbotas
Copy link

@turbotas turbotas commented Mar 2, 2018

… This option seeds the torch RNG with a selected integer value.

Default sample.lua behavior is unchanged - a random value is seeded if the option is omitted or set 0.

The option honours the verbose flag and reports the seed, even the random seed, to permit an identical rerun if required.

Please note - this does not affect the training at all - only the sample.lua

… This option seeds the torch RNG with a selected integer value.

Default behavior is unchanged - a random value is seeded if the option is omitted or set 0.

The option honours the verbose flag and reports the seed, even the random seed, to permit an identical rerun if required.

Please note - this does not affect the training at all - only the sample.lua
Copy link
Collaborator

@ChrisCummins ChrisCummins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @turbotas, sorry for my slow response. This looks great, thanks :)

Unfortunately I don't have the ability to run torch-run at the moment, could someone please checkout this PR and verify it?

I've added a couple of comments for minor issues. Please also add an entry in docs/flags.md documenting this new feature.

sample.lua Show resolved Hide resolved
if opt.seed == 0 then
opt.seed = torch.random()
end
torch.manualSeed(opt.seed)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be simpler to force a manual seed only if -seed argument is set:

if <flag set>:
  torch.manualSeed(...)
end

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this code looks odd. The reason I did this is to make sure that if you see some output that you would like to see again, and if you had the verbose flag set to report the seed, you can re-run by then including the seed - even if you didn't originally set the seed flag. So the code always sets a seed - using your provided value if you set one and a random number if you didn't (or specified zero!). I thought this was clever ;-)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay that makes sense.

@turbotas
Copy link
Author

turbotas commented Mar 13, 2018 via email

@turbotas
Copy link
Author

I think I fixed comments and issues at commit 5d952d8 but not smart enough with git to know if I need to submit a new Pull request.

@ChrisCummins
Copy link
Collaborator

Thanks @turbotas , yep the PR picked up your new commit.

Can someone please run this branch and let me know it works as expected? It doesn't look like there's much room for anything expected, but would like a second opinion before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants