【发布时间】:2017-01-18 11:23:45
【问题描述】:
我对 torch.CmdLine:text() 的使用感到困惑。
文档说明如下:
text(string)
Logs a custom text message.
我的理解是它在日志文件和控制台中添加了一些文本消息。我刚刚尝试了文档页面中提供的示例代码。
cmd = torch.CmdLine()
cmd:text()
cmd:text('Training a simple network')
cmd:text()
cmd:text('Options')
cmd:option('-seed',123,'initial random seed')
cmd:option('-booloption',false,'boolean option')
cmd:option('-stroption','mystring','string option')
cmd:text()
-- parse input params
params = cmd:parse(arg)
params.rundir = cmd:string('experiment', params, {dir=true})
paths.mkdir(params.rundir)
-- create log file
cmd:log(params.rundir .. '/log', params)
我在命令行和日志文件中得到以下输出:
[program started on Sat Sep 10 14:55:30 2016]
[command line arguments]
stroption mystring
booloption false
seed 123
rundir experiment
[----------------------]
我没有看到调用 text() 方法的任何输出。
有人可以帮我理解这里发生了什么以及 text() 方法的正确用法吗?
【问题讨论】:
-
你想做什么?
:text()不会自动输出文本,似乎是为了解释它正在解析的命令的用法。 github.com/torch/torch7/blob/master/CmdLine.lua在命令中添加-help或者执行cmd:help()后可以看到文字 -
@BasilioGerman 感谢您的评论。我了解 text() 的用法。