ypxie / pytorch-NeuCom

Pytorch implementation of DeepMind's differentiable neural computer paper.
94 stars 15 forks source link

Error running copy example #5

Closed jramapuram closed 7 years ago

jramapuram commented 7 years ago
Using CPU.                   
Iteration 0/100000Traceback (most recent call last):
  File "train.py", line 177, in <module>
    output, _ = ncomputer(input_data)
  File "/home/jramapuram/.venv/lib/python2.7/site-packages/torch/nn/modules/module.py", line 206, in __call__
    result = self.forward(*input, **kwargs)
  File "../../neucom/dnc.py", line 108, in forward
    interface['erase_vector']
  File "../../neucom/memory.py", line 398, in write
    allocation_weight = self.get_allocation_weight(sorted_usage, free_list)
  File "../../neucom/memory.py", line 144, in get_allocation_weight
    flat_unordered_allocation_weight.cpu()
  File "/home/jramapuram/.venv/lib/python2.7/site-packages/torch/autograd/variable.py", line 629, in scatter_
    return Scatter(dim, True)(self, index, source)
RuntimeError: a leaf Variable that requires grad has been used in an in-place operation.
ypxie commented 7 years ago

Hi, I have fixed this bug, it's probably caused by the updating of the pytorch. Please try the latest version. :)

jramapuram commented 7 years ago

Tried this with a version built from master as well:

(conda3) ➜  Copy git:(master) python train.py 
Using CPU.
Iteration 0/100000Traceback (most recent call last):
  File "train.py", line 177, in <module>
    output, _ = ncomputer(input_data)
  File "/opt/anaconda/envs/conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 225, in __call__
    result = self.forward(*input, **kwargs)
  File "../../neucom/dnc.py", line 108, in forward
    interface['erase_vector']
  File "../../neucom/memory.py", line 383, in write
    lookup_weight = self.get_content_address(memory_matrix, key, strength)
  File "../../neucom/memory.py", line 78, in get_content_address
    cos_dist = cosine_distance(memory_matrix, query_keys)
  File "../../neucom/utils.py", line 157, in cosine_distance
    normalized_mem = torch.div(memory_matrix, memory_norm.expand_as(memory_matrix) + 1e-8)
  File "/opt/anaconda/envs/conda3/lib/python3.6/site-packages/torch/autograd/variable.py", line 698, in expand_as
    return Expand.apply(self, tensor.size())
  File "/opt/anaconda/envs/conda3/lib/python3.6/site-packages/torch/autograd/_functions/tensor.py", line 113, in forward
    result = i.expand(*new_size)
RuntimeError: The expanded size of the tensor (16) must match the existing size (15) at non-singleton dimension 2. at /home/jramapuram/projects/pytorch/torch/lib/TH/generic/THTensor.c:308
ypxie commented 7 years ago

I can run it correclty. Please use the updated code.

jramapuram commented 7 years ago

pytorch git revision: ebdec9a837074a303fd5ffb6f319cd593955becc pytorch-Neucom git revision: 2fe2a69583369225ad5e522a663b1c1f80a793c2

ypxie commented 7 years ago

please use the latest update of pytorch-Neucom :6047382e6f934a70b92c9ba18c748b59c2a6275b

jramapuram commented 7 years ago

Yup, ty!