ruiyan1995 / Group-Activity-Recognition

A novel Participation-Contributed Temporal Dynamic Model for Group Activity Recognition
25 stars 6 forks source link

AttributeError: 'Variable' object has no attribute 'item' #3

Closed qdinfish closed 5 years ago

qdinfish commented 5 years ago

After pre-processing, I encounter following issue , could you help take a look at it ?

Please wait for training action! Needs 200min for 20epochs(VD). data_confs Namespace(batch_size={'test': 10, 'trainval': 300}, data_type='img', dataset_folder='/media/sys511/0C78B85C78B845EC/database/VD/imgs_ranked', label_type='action') AlexNet_LSTM( (features): Sequential( (0): Conv2d(3, 64, kernel_size=(11, 11), stride=(4, 4), padding=(2, 2)) (1): ReLU(inplace) (2): MaxPool2d(kernel_size=(3, 3), stride=(2, 2), dilation=(1, 1), ceil_mode=False) (3): Conv2d(64, 192, kernel_size=(5, 5), stride=(1, 1), padding=(2, 2)) (4): ReLU(inplace) (5): MaxPool2d(kernel_size=(3, 3), stride=(2, 2), dilation=(1, 1), ceil_mode=False) (6): Conv2d(192, 384, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) (7): ReLU(inplace) (8): Conv2d(384, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) (9): ReLU(inplace) (10): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) (11): ReLU(inplace) (12): MaxPool2d(kernel_size=(3, 3), stride=(2, 2), dilation=(1, 1), ceil_mode=False) ) (fc): Sequential( (0): Dropout(p=0.5) (1): Linear(in_features=9216, out_features=4096, bias=True) (2): ReLU(inplace) ) (LSTM): LSTM(4096, 3000, batch_first=True) (classifier): Linear(in_features=3000, out_features=9, bias=True) ) solver_confs Namespace(criterion=CrossEntropyLoss( ), data_loaders={'test': <torch.utils.data.dataloader.DataLoader object at 0x7fef6b2da1d0>, 'trainval': <torch.utils.data.dataloader.DataLoader object at 0x7fef6b2da110>}, data_sizes={'test': 155260, 'trainval': 408010}, dataset_name='VD', exp_lr_scheduler=<torch.optim.lr_scheduler.StepLR object at 0x7fef6b2da590>, gpu=False, mode='trainval_action', num_epochs=10, optimizer=SGD ( Parameter Group 0 dampening: 0 initial_lr: 0.001 lr: 0.001 momentum: 0.9 nesterov: False weight_decay: 0 ), stage='action') Epoch 0/9

Traceback (most recent call last): File "GAR.py", line 33, in Action.trainval() File "/home/sys511/Group-Activity-Recognition-1/Runtime/Piplines.py", line 58, in trainval self.solver.train_model() File "/home/sys511/Group-Activity-Recognition-1/Solver.py", line 83, in train_model self.training(inputs, labels, phase) File "/home/sys511/Group-Activity-Recognition-1/Solver.py", line 54, in training self.running_loss += loss.item AttributeError: 'Variable' object has no attribute 'item'

ruiyan1995 commented 5 years ago

After pre-processing, I encounter following issue , could you help take a look at it ?

Please wait for training action! Needs 200min for 20epochs(VD).

data_confs Namespace(batch_size={'test': 10, 'trainval': 300}, data_type='img', dataset_folder='/media/sys511/0C78B85C78B845EC/database/VD/imgs_ranked', label_type='action') AlexNet_LSTM( (features): Sequential( (0): Conv2d(3, 64, kernel_size=(11, 11), stride=(4, 4), padding=(2, 2)) (1): ReLU(inplace) (2): MaxPool2d(kernel_size=(3, 3), stride=(2, 2), dilation=(1, 1), ceil_mode=False) (3): Conv2d(64, 192, kernel_size=(5, 5), stride=(1, 1), padding=(2, 2)) (4): ReLU(inplace) (5): MaxPool2d(kernel_size=(3, 3), stride=(2, 2), dilation=(1, 1), ceil_mode=False) (6): Conv2d(192, 384, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) (7): ReLU(inplace) (8): Conv2d(384, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) (9): ReLU(inplace) (10): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) (11): ReLU(inplace) (12): MaxPool2d(kernel_size=(3, 3), stride=(2, 2), dilation=(1, 1), ceil_mode=False) ) (fc): Sequential( (0): Dropout(p=0.5) (1): Linear(in_features=9216, out_features=4096, bias=True) (2): ReLU(inplace) ) (LSTM): LSTM(4096, 3000, batch_first=True) (classifier): Linear(in_features=3000, out_features=9, bias=True) ) solver_confs Namespace(criterion=CrossEntropyLoss( ), data_loaders={'test': <torch.utils.data.dataloader.DataLoader object at 0x7fef6b2da1d0>, 'trainval': <torch.utils.data.dataloader.DataLoader object at 0x7fef6b2da110>}, data_sizes={'test': 155260, 'trainval': 408010}, dataset_name='VD', exp_lr_scheduler=<torch.optim.lr_scheduler.StepLR object at 0x7fef6b2da590>, gpu=False, mode='trainval_action', num_epochs=10, optimizer=SGD ( Parameter Group 0 dampening: 0 initial_lr: 0.001 lr: 0.001 momentum: 0.9 nesterov: False weight_decay: 0 ), stage='action') Epoch 0/9 Traceback (most recent call last): File "GAR.py", line 33, in Action.trainval() File "/home/sys511/Group-Activity-Recognition-1/Runtime/Piplines.py", line 58, in trainval self.solver.train_model() File "/home/sys511/Group-Activity-Recognition-1/Solver.py", line 83, in train_model self.training(inputs, labels, phase) File "/home/sys511/Group-Activity-Recognition-1/Solver.py", line 54, in training self.running_loss += loss.item AttributeError: 'Variable' object has no attribute 'item'

.item() is the new feature in Pytorch 0.4! Two solutions: 1) upgrade the Pytorch to 0.4; 2) self.running_loss += loss.data[0]

qdinfish commented 5 years ago

upgrade the Pytorch version , issue has been fixed. Thanks a lot!