attention-networks-for-classification
attention-networks-for-classification copied to clipboard
how could I run this on Python 3
RuntimeError Traceback (most recent call last)
C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py in call(self, *input, **kwargs) 222 for hook in self._forward_pre_hooks.values(): 223 hook(self, input) --> 224 result = self.forward(*input, **kwargs) 225 for hook in self._forward_hooks.values(): 226 hook_result = hook(self, input, result)
C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py in call(self, *input, **kwargs) 222 for hook in self._forward_pre_hooks.values(): 223 hook(self, input) --> 224 result = self.forward(*input, **kwargs) 225 for hook in self._forward_hooks.values(): 226 hook_result = hook(self, input, result)
C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\rnn.py in forward(self, input, hx) 160 flat_weight=flat_weight 161 ) --> 162 output, hidden = func(input, self.all_weights, hx) 163 if is_packed: 164 output = PackedSequence(output, batch_sizes)
C:\ProgramData\Anaconda3\lib\site-packages\torch\nn_functions\rnn.py in forward(input, *fargs, **fkwargs) 349 else: 350 func = AutogradRNN(*args, **kwargs) --> 351 return func(input, *fargs, **fkwargs) 352 353 return forward
C:\ProgramData\Anaconda3\lib\site-packages\torch\nn_functions\rnn.py in forward(input, weight, hidden) 242 input = input.transpose(0, 1) 243 --> 244 nexth, output = func(input, hidden, weight) 245 246 if batch_first and batch_sizes is None:
C:\ProgramData\Anaconda3\lib\site-packages\torch\nn_functions\rnn.py in forward(input, hidden, weight) 82 l = i * num_directions + j 83 ---> 84 hy, output = inner(input, hidden[l], weight[l]) 85 next_hidden.append(hy) 86 all_output.append(output)
C:\ProgramData\Anaconda3\lib\site-packages\torch\nn_functions\rnn.py in forward(input, hidden, weight) 111 steps = range(input.size(0) - 1, -1, -1) if reverse else range(input.size(0)) 112 for i in steps: --> 113 hidden = inner(input[i], hidden, *weight) 114 # hack to handle LSTM 115 output.append(hidden[0] if isinstance(hidden, tuple) else hidden)
C:\ProgramData\Anaconda3\lib\site-packages\torch\nn_functions\rnn.py in GRUCell(input, hidden, w_ih, w_hh, b_ih, b_hh) 54 gi = F.linear(input, w_ih, b_ih) 55 gh = F.linear(hidden, w_hh, b_hh) ---> 56 i_r, i_i, i_n = gi.chunk(3, 1) 57 h_r, h_i, h_n = gh.chunk(3, 1) 58
C:\ProgramData\Anaconda3\lib\site-packages\torch\autograd\variable.py in chunk(self, num_chunks, dim) 745 746 def chunk(self, num_chunks, dim=0): --> 747 return Chunk.apply(self, num_chunks, dim) 748 749 def squeeze(self, dim=None):
C:\ProgramData\Anaconda3\lib\site-packages\torch\autograd_functions\tensor.py in forward(ctx, i, num_chunks, dim) 540 def forward(ctx, i, num_chunks, dim=0): 541 ctx.dim = dim --> 542 result = i.chunk(num_chunks, dim) 543 ctx.mark_shared_storage(*((i, chunk) for chunk in result)) 544 return result
C:\ProgramData\Anaconda3\lib\site-packages\torch\tensor.py in chunk(self, n_chunks, dim)
172 See :func:torch.chunk
.
173 """
--> 174 return torch.chunk(self, n_chunks, dim)
175
176 def matmul(self, other):
C:\ProgramData\Anaconda3\lib\site-packages\torch\functional.py in chunk(tensor, chunks, dim) 42 if dim < 0: 43 dim += tensor.dim() ---> 44 split_size = (tensor.size(dim) + chunks - 1) // chunks 45 return split(tensor, split_size, dim) 46
RuntimeError: invalid argument 2: dimension 1 out of range of 1D tensor at d:\projects\pytorch\torch\lib\th\generic/THTensor.c:24
Got this runtime Error when I try to run it on Python3. Could anyone help me with this?
Thanks a lot!
I have the same problem, in Python 3.
I am sorry but I will no longer be maintaining this project, especially when it comes to Python 3 support. Please have a look at the other implementation of the same attention model. https://github.com/EdGENetworks/anuvada
Thanks.