I’m trying to upgrade this Mem2Seq repository I’m running the following command
python3 main_train.py -lr=0.001 -layer=1 -hdd=128 -dr=0.2 -dec=Mem2Seq -bsz=8 -ds=kvr -t= top_ptr_i.squeeze()[i].item()
Here is the error code:
File "main_train.py", line 62, in <module> acc = model.evaluate(dev,avg_best, BLEU) File "/content/Mem2Seq/models/Mem2Seq.py", line 281, in evaluate data_dev[2],data_dev[3],data_dev[4],data_dev[5],data_dev[6]) File "/content/Mem2Seq/models/Mem2Seq.py", line 202, in evaluate_batch next_in = [top_ptr_i.squeeze()[i].item() if(int(toppi.squeeze()[i].item()) < input_lengths[i]-1) else topvi.squeeze()[i].item() for i in range(batch_size)] File "/content/Mem2Seq/models/Mem2Seq.py", line 202, in <listcomp> next_in = [top_ptr_i.squeeze()[i].item() if(int(toppi.squeeze()[i].item()) < input_lengths[i]-1) else topvi.squeeze()[i].item() for i in range(batch_size)] IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number
The specific error is but IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number
. However, I’m finding the error code very odd since as you can see in the stack trace I already converted it to .item(). Anyone have experience with this?