Skip to content
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

Problem using adamax under lua5.2 #160

Open
Mathieu-Seurin opened this issue Jul 5, 2017 · 0 comments
Open

Problem using adamax under lua5.2 #160

Mathieu-Seurin opened this issue Jul 5, 2017 · 0 comments

Comments

@Mathieu-Seurin
Copy link

Mathieu-Seurin commented Jul 5, 2017

Hello,

I run into some problems using adamax

/home/XXXX/torch/install/share/lua/5.2/optim/adamax.lua:48: attempt to call global 'unpack' (a nil value)
stack traceback:
	/home/XXXX/torch/install/share/lua/5.2/optim/adamax.lua:48: in function 'adamax'

I installed torch under lua5.2 instead of luaJIT and it seems that, in lua5.2 the function 'unpack' was replaced by 'table.unpack'

See : https://stackoverflow.com/questions/25794364/lua-trouble-attempt-to-call-global-unpack-a-nil-value

EDIT (Sample code)

require 'nn'
require 'optim'

model = nn.Sequential() 
inputs = 2; outputs = 1
model:add(nn.Linear(inputs, outputs))

criterion = nn.MSECriterion()

params, gradParams = model:getParameters()
config = {learningRate = 1e-3,momentum = 0.5}

function feval(params)
   gradParams:zero()
   local outputs = model:forward(torch.ones(2))
   local loss = criterion:forward(outputs, torch.zeros(1))
   local dloss_doutputs = criterion:backward(outputs, torch.zeros(1))
   model:backward(torch.ones(2), dloss_doutputs)
   return loss, gradParams
end

optim.adamax(feval, params, optimState)
/home/XXXX/torch/install/bin/lua: /home/XXXX/torch/install/share/lua/5.2/optim/adamax.lua:48: attempt to call global 'unpack' (a nil value)
stack traceback:
	/home/XXXX/torch/install/share/lua/5.2/optim/adamax.lua:48: in function 'adamax'
	ex_fail.lua:22: in main chunk
	[C]: in function 'dofile'
	...urin/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
	[C]: in ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant