【问题标题】:Torch CmdLine:text behavior is puzzlingTorch CmdLine:文本行为令人费解
【发布时间】: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() 的用法。

标签: lua torch


【解决方案1】:
CmdLine 的

:text(string) 方法只会在使用 -help 参数运行脚本时打印 string (以及当您决定向用户显示帮助时)通过它的 :help() 方法)。

例子:

th MyScript.lua -help

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-02
    • 2020-06-19
    • 2020-10-30
    • 2023-03-12
    • 1970-01-01
    • 2011-03-27
    • 2010-11-15
    相关资源
    最近更新 更多