zhoubolei / TRN-pytorch

Temporal Relation Networks
http://relation.csail.mit.edu/
Other
787 stars 190 forks source link

Error : Training 4 Classes #82

Open NaeemKhan333 opened 4 years ago

NaeemKhan333 commented 4 years ago

I am training 4 classes on my own dataset.After doing all the required process for the training. When I have started the training, I am Facing this following issue. Can Anybody help me to sort this problem.Thanks

video number:20 group: first_conv_weight has 1 params, lr_mult: 1, decay_mult: 1 group: first_conv_bias has 1 params, lr_mult: 2, decay_mult: 0 group: normal_weight has 71 params, lr_mult: 1, decay_mult: 1 group: normal_bias has 71 params, lr_mult: 2, decay_mult: 0 group: BN scale/shift has 2 params, lr_mult: 1, decay_mult: 0 Freezing BatchNorm2D except the first one. Traceback (most recent call last): File "main.py", line 333, in main() File "main.py", line 135, in main train(train_loader, model, criterion, optimizer, epoch, log_training) File "main.py", line 183, in train top1.update(prec1[0], input.size(0)) IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number

shank885 commented 3 years ago

I had the same issue and the below step fixed it.

Change this line: top1.update(prec1[0], input.size(0))

To this: top1.update(prec1.item(), input.size(0))