参考~/torch/pkg/torch/doc/cmdline.md
--setting the opt
local M = { }
function M.parse(arg)
local cmd = torch.CmdLine()
cmd:text()
cmd:text('Torch-7 net Training demo')
cmd:text()
cmd:text('Options:')
cmd:option('-manualSeed', 0, 'Manually set RNG seed')
cmd:option('-resume', 'none', 'Resume from the latest checkpoint in this directory')
cmd:option('-type', 'float', 'float -> cpu; cuda -> gpu')
cmd:option('-save', 'checkpoints', 'Directory in which to save checkpoints')
cmd:option('-max_epoch', 0, 'Number of total epochs to run')
local opt = cmd:parse(arg or {})
return opt
end
return M
需要解释cmd:option(‘-manualSeed’, 0, ‘Manually set RNG seed’)这个函数:option(name, default, help)
cmd:option(‘-A’,B,’C’) A代表参数名称,B表示默认值,C表示提示。
该类下其他函数用法:
torch.CmdLine:log(filename,parameter_table) --write the parameter_table to the filename
torch.CmdLine:parse(arg) --返回参数表,由option定义
torch.CmdLine:silent() --只会保留向文件中写入功能,其他输出silent