Alejandro Simkievich
Alejandro Simkievich

Reputation: 3792

lua - invalid argument type

I am a newbie to Lua. Currently getting the following error message:

invalid argument type for argument -model (should be the model checkpoint 
to use for sampling)
Usage: [options] <model>

I am sure it is something pretty easy to solve, but cannot manage to find the solution.

The 'model' is a file lm_checkpoint_epoch50.00_2.7196.t7, which is in the directory

/home/ubuntu/xxx/nn/cv

I am running the program from the parent directory (/home/ubuntu/xxx/nn)

I have tried out the following options to run the program (from one directory above the one the model is saved):

th sample.lua - model lm_chelm_checkpoint_epoch50.00_2.5344.t7
th sample.lua lm_chelm_checkpoint_epoch50.00_2.5344.t7
th sample.lua /cv/lm_chelm_checkpoint_epoch50.00_2.5344.t7
th sample.lua - /cv/model lm_chelm_checkpoint_epoch50.00_2.5344.t7

Also, the program has a torch.CmdLine() object where :argument equals '/cv/lm_checkpoint_epoch50.00_2.7196.t7'. The program prints the parameters, so that you see the following output on the screen:

Options
<model>      /cv/lm_checkpoint_epoch50.00_2.7196.t7

so it finds a value for argument 'model', which is picked up from the .lua file, not the parameter in the command line. This file is a valid mode.

Pretty lost, hope someone relates to this issue. Thanks.

Upvotes: 1

Views: 1731

Answers (1)

Alejandro Simkievich
Alejandro Simkievich

Reputation: 3792

found the issue - it was a bug as smhx suggested. I inadvertently changed the source code from:

require 'torch'
cmd = torch.CmdLine()
cmd:argument('-model','model checkpoint to use for sampling')

Note that there is no argument in the source code. To:

cmd:argument('-model','/cv/model lm_chelm_checkpoint_epoch50.00_2.5344.t7'
'model checkpoint to use for sampling')

So the argument must be passed through the command line, not the source code. With parameters, it is different - you can include them in the source code.

So if I change back the source code and run the following from the command line:

th sample.lua cv/lm_chelm_checkpoint_epoch50.00_2.5344.t7

it works.

Upvotes: 2

Related Questions