piergiaj / super-events-cvpr18

Code for our CVPR 2018 paper "Learning Latent Super-Events to Detect Multiple Activities in Videos"
MIT License
123 stars 34 forks source link

RuntimeError: invalid argument 7: expected 3D tensor #3

Closed lwq1122 closed 5 years ago

lwq1122 commented 6 years ago

Hi, I found some errors when I run train_model.py and I got this error in super-event.py, and I use pytorch-i3d to extract features first:

Traceback (most recent call last): File "train_model.py", line 260, in rgb_results = eval_model(rgb_model, dataloaders['val'], baseline=False) File "train_model.py", line 123, in evalmodel outputs, loss, probs, = run_network(model, data, 0, baseline) File "train_model.py", line 142, in run_network outputs = model([inputs, torch.sum(mask, 1)]) File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 357, in call result = self.forward(*input, **kwargs) File "/home/super-events-cvpr18/super_event.py", line 55, in forward super_event = torch.bmm(cls_wts.expand(inp[0].size()[0], -1, -1), super_event) RuntimeError: invalid argument 7: expected 3D tensor at /pytorch/torch/lib/THC/generic/THCTensorMathBlas.cu:457

According to comment, I know we want change super-event(B×2×D3) to super-event(B×C×D3) But I print 'cls_wts.expand(inp[0].size()[0], -1, -1)' ,it's a 3D Tensor((1L, 157L, 2L)), super-event is a 4D Tensor((1L, 2L, 1024L, 3L)). They can't do torch.bmm()

Can you help me fix this error? Thank you so much!!

piergiaj commented 6 years ago

I am not sure what is causing this error. The code runs fine for me and several others who have used it. Here are 2 suggestions to try:

1) Make sure you are using pytorch 0.3. Newer versions may cause errors. 2) Make sure your batch size >1, a batch size of 1 could cause problems particularly with the squeeze function.

lwq1122 commented 6 years ago

Thank you very much