adambielski / CapsNet-pytorch

PyTorch implementation of NIPS 2017 paper Dynamic Routing Between Capsules
BSD 3-Clause "New" or "Revised" License
489 stars 73 forks source link

Deprecated #9

Open raul1968 opened 5 years ago

raul1968 commented 5 years ago

/home/raul/Desktop/CapsNet-pytorch/net.py:28: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument. c = F.softmax(self.b) /home/raul/Desktop/CapsNet-pytorch/net.py:38: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument. c = F.softmax(b_batch.view(-1, output_caps)).view(-1, input_caps, output_caps, 1) Traceback (most recent call last): File "/home/raul/Desktop/CapsNet-pytorch/net.py", line 275, in train(epoch) File "/home/raul/Desktop/CapsNet-pytorch/net.py", line 244, in train

    • batch_idx / len(train_loader), loss.data[0])) IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number
luo3300612 commented 5 years ago

use loss.item() instead of loss.data[0]

adambielski commented 5 years ago

There were some breaking changes in newer PyTorch versions; I used version 0.3.0 when I was writing the code.