Seq2seq가 내가 하려는 연구의 기초가 되기 때문에
직접 짜지는 않고.....
있는 코드 돌려보기로 했다.
https://github.com/macournoyer/neuralconvo
코드는 torch 코드
그리고 겪게 되는 에러들 포스팅
1.
/home/xx/torch/install/share/lua/5.1/nn/Select.lua:10: bad argument #3 to 'select' (out of range at /tmp/luarocks_cutorch-scm-1-5327/cutorch/lib/THC/generic/THCTensor.c:386)
흠.. 잘은 모르겠지만 Select.lua의 10번째 줄에서 에러가 나는 것 같다.
https://github.com/torch/nn/blob/master/Select.lua
근데 웹에 나온 Select.lua랑 코드가 달랐다.
local Select, parent = torch.class('nn.Select', 'nn.Module') function Select:__init(dimension,index) parent.__init(self) self.dimension = dimension self.index = index end function Select:updateOutput(input) local index = self.index < 0 and input:size(self.dimension) + self.index + 1 or self.index local output = input:select(self.dimension, index); self.output:resizeAs(output) return self.output:copy(output) end function Select:updateGradInput(input, gradOutput) local index = self.index < 0 and input:size(self.dimension) + self.index + 1 or self.index self.gradInput:resizeAs(input) self.gradInput:zero() self.gradInput:select(self.dimension,index):copy(gradOutput) return self.gradInput end
여기서
local index = self.index < 0 and input:size(self.dimension) + self.index + 1 or self.index
이 부분의 코드가 없고, 대신 select에 인자로 주는 index가 local index가 아니고 self.index
사실 여기가 문제란 걸 발견한 건,
우선 이 값을 찍어봐야 할 것 같아서
self.dimension과 self.index를 찍어봤다.
각각 1과 -1의 값이 나오길래, 왠지 -1이 index이면 안 될 것 같아서 ㅋㅋㅋㅋ
그래서 저 없는 줄을 넣었더니 문제 해결.
nn 패키지를 업데이트를 안 해서 그런 것 같기도 하고.
우선 대충 해결데쓰!
'공부하는 > 기계학습[ML]' 카테고리의 다른 글
LDA(Latent Dirichlet Allocation) 정리 (0) | 2016.09.06 |
---|---|
Generative Model과 Discriminative Model 차이 (0) | 2016.05.30 |