-
Notifications
You must be signed in to change notification settings - Fork 511
Added a '-seed' option to sample.lua to allow for an identical rerun.… #219
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,12 +13,23 @@ cmd:option('-temperature', 1) | |
cmd:option('-gpu', 0) | ||
cmd:option('-gpu_backend', 'cuda') | ||
cmd:option('-verbose', 0) | ||
cmd:option('-seed', 0) | ||
local opt = cmd:parse(arg) | ||
|
||
|
||
local checkpoint = torch.load(opt.checkpoint) | ||
local model = checkpoint.model | ||
|
||
if opt.seed == 0 then | ||
opt.seed = torch.random() | ||
end | ||
torch.manualSeed(opt.seed) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be simpler to force a manual seed only if
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ;-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah okay that makes sense. |
||
|
||
local msg | ||
msg = string.format('Random number seed: %d', opt.seed) | ||
if opt.verbose == 1 then print(msg) end | ||
|
||
|
||
local msg | ||
if opt.gpu >= 0 and opt.gpu_backend == 'cuda' then | ||
require 'cutorch' | ||
|
Uh oh!
There was an error while loading. Please reload this page.