{"action":"created","issue":{"url":"https://api.github.com/repos/torch/nn/issues/1182","repository_url":"https://api.github.com/repos/torch/nn","labels_url":"https://api.github.com/repos/torch/nn/issues/1182/labels{/name}","comments_url":"https://api.github.com/repos/torch/nn/issues/1182/comments","events_url":"https://api.github.com/repos/torch/nn/issues/1182/events","html_url":"https://github.com/torch/nn/issues/1182","id":217427464,"number":1182,"title":"Error in makeInputContiguous() function of LookupTable! ","user":{"login":"jKhurana","id":10388355,"avatar_url":"https://avatars0.githubusercontent.com/u/10388355?v=3","gravatar_id":"","url":"https://api.github.com/users/jKhurana","html_url":"https://github.com/jKhurana","followers_url":"https://api.github.com/users/jKhurana/followers","following_url":"https://api.github.com/users/jKhurana/following{/other_user}","gists_url":"https://api.github.com/users/jKhurana/gists{/gist_id}","starred_url":"https://api.github.com/users/jKhurana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jKhurana/subscriptions","organizations_url":"https://api.github.com/users/jKhurana/orgs","repos_url":"https://api.github.com/users/jKhurana/repos","events_url":"https://api.github.com/users/jKhurana/events{/privacy}","received_events_url":"https://api.github.com/users/jKhurana/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-03-28T02:09:44Z","updated_at":"2017-03-28T02:25:31Z","closed_at":null,"body":"I am creating an encoder. Below is my code:\r\n\r\n```\r\nrequire 'nn'\r\n\r\n-- basic lstm cell\r\n-- input; x, previsou_state\r\nfunction lstm(x, prev_c, prev_h)\r\n  -- Calculate all four gates in one go\r\n  local i2h = nn.Linear(opt.rnn_size, 4 * opt.rnn_size)(x)\r\n  local h2h = nn.Linear(opt.rnn_size, 4 * opt.rnn_size)(prev_h)\r\n  local gates = nn.CAddTable()({i2h, h2h})\r\n  \r\n  -- Reshape to (batch_size, n_gates, hid_size)\r\n  -- Then slize the n_gates dimension\r\n  local reshaped_gates =  nn.Reshape(4, opt.rnn_size)(gates)\r\n  local sliced_gates = nn.SplitTable(2)(reshaped_gates)\r\n  \r\n  -- Use select gate to fetch each gate and apply nonlinearity\r\n  local in_gate          = nn.Sigmoid()(nn.SelectTable(1)(sliced_gates)):annotate{name='in_gate'}\r\n  local in_transform     = nn.Tanh()(nn.SelectTable(2)(sliced_gates)):annotate{name='in_transform'}\r\n  local forget_gate      = nn.Sigmoid()(nn.SelectTable(3)(sliced_gates)):annotate{name='forget_gate'}\r\n  local out_gate         = nn.Sigmoid()(nn.SelectTable(4)(sliced_gates)):annotate{name='out_gate'}\r\n\r\n  local next_c           = nn.CAddTable()({\r\n      nn.CMulTable()({forget_gate, prev_c}):annotate{name='next_c_1'},\r\n      nn.CMulTable()({in_gate, in_transform}):annotate{name='next_c_2'}\r\n  })\r\n  local next_h           = nn.CMulTable()({out_gate, nn.Tanh()(next_c)}):annotate{name='next_h'}\r\n\r\n  return next_c, next_h\r\nend\r\n\r\n\r\nfunction create_singlelayer_lookup_encoder(w_size,opt)\r\n  -- input nngraph nodes\r\n  x = nn.Identity()()\r\n  prev_s = nn.Identity()()\r\n\r\n  -- make lookup table\r\n  local x_in = nn.LookupTable(w_size,opt.rnn_size)(x):annotate{name=\"enc_lookup\"}\r\n  local next_s = {}\r\n  local splitted = {prev_s:split(2)}\r\n  local next_c,next_h = lstm(x_in,splitted[1],splitted[2])\r\n  --print(type(next_h))\r\n  table.insert(next_s,next_c)\r\n  table.insert(next_s,next_h)\r\n\r\n  local m = nn.gModule({x, prev_s}, {nn.Identity()(next_s)})\r\n  return m\r\nend\r\n\r\nlocal cmd = torch.CmdLine()\r\ncmd:option('-rnn_size', 150, 'size of LSTM internal state')\r\nopt = cmd:parse(arg)\r\n\r\nmodel = create_singlelayer_lookup_encoder(10,opt)\r\n```\r\n\r\nWhen I run the above code it gives the following error:\r\n`lua: .../jkhurana/torch/install/share/lua/5.2/nn/LookupTable.lua:59: attempt to index local 'input' (a nil value)`\r\n\r\nStackTrace:\r\n\r\n```\r\nstack traceback:\r\n\t.../jkhurana/torch/install/share/lua/5.2/nn/LookupTable.lua:59: in function 'makeInputContiguous'\r\n\t.../jkhurana/torch/install/share/lua/5.2/nn/LookupTable.lua:71: in function <.../jkhurana/torch/install/share/lua/5.2/nn/LookupTable.lua:68>\r\n\t(...tail calls...)\r\n\t.../home/jkhurana/torch/install/share/lua/5.2/nn/Module.lua:339: in function <.../home/jkhurana/torch/install/share/lua/5.2/nn/Module.lua:338>\r\n\t[C]: in ?\r\n\tencoder.lua:42: in function 'create_singlelayer_lookup_encoder'\r\n\tencoder.lua:58: in main chunk\r\n\t[C]: in ?\r\n```"},"comment":{"url":"https://api.github.com/repos/torch/nn/issues/comments/289643418","html_url":"https://github.com/torch/nn/issues/1182#issuecomment-289643418","issue_url":"https://api.github.com/repos/torch/nn/issues/1182","id":289643418,"user":{"login":"jKhurana","id":10388355,"avatar_url":"https://avatars0.githubusercontent.com/u/10388355?v=3","gravatar_id":"","url":"https://api.github.com/users/jKhurana","html_url":"https://github.com/jKhurana","followers_url":"https://api.github.com/users/jKhurana/followers","following_url":"https://api.github.com/users/jKhurana/following{/other_user}","gists_url":"https://api.github.com/users/jKhurana/gists{/gist_id}","starred_url":"https://api.github.com/users/jKhurana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jKhurana/subscriptions","organizations_url":"https://api.github.com/users/jKhurana/orgs","repos_url":"https://api.github.com/users/jKhurana/repos","events_url":"https://api.github.com/users/jKhurana/events{/privacy}","received_events_url":"https://api.github.com/users/jKhurana/received_events","type":"User","site_admin":false},"created_at":"2017-03-28T02:25:31Z","updated_at":"2017-03-28T02:25:31Z","body":"I am only creating model here, not doing training. Once I will call forward() method on module, I will pass the input to the module. Is it not similar to the \"A network with containers\" section of the following link:\r\nhttps://github.com/torch/nngraph\r\n"}}
{"actor":{"display_login":"jKhurana"}}