zhoubolei / TRN-pytorch

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

RuntimeError: invalid argument 2: out of range at /opt/conda/conda-bld/pytorch_1525796793591/work/torch/lib/THC/generic/THCTensor.c:23 when run 'test_rgb_something.sh' #30

Open kmyfoer opened 5 years ago

kmyfoer commented 5 years ago

Traceback (most recent call last): File "test_models.py", line 78, in img_feature_dim=args.img_feature_dim, File "/media/data/kmy/TRN-ATT/models.py", line 60, in init self.consensus = TRNmodule.return_TRN(consensus_type, self.img_feature_dim, self.num_segments, num_class) File "/media/data/kmy/TRN-ATT/TRNmodule.py", line 283, in return_TRN TRNmodel = RelationModuleMultiScaleWithAtt(img_feature_dim, num_frames, num_class) File "/media/data/kmy/TRN-ATT/TRNmodule.py", line 91, in init nn.Linear(len(self.scales)*self.num_class, len(self.scales)), File "/home/kongmy/anaconda3/envs/pytorch/lib/python3.5/site-packages/torch/nn/modules/linear.py", line 46, in init self.reset_parameters() File "/home/kongmy/anaconda3/envs/pytorch/lib/python3.5/site-packages/torch/nn/modules/linear.py", line 49, in reset_parameters stdv = 1. / math.sqrt(self.weight.size(1)) RuntimeError: invalid argument 2: out of range at /opt/conda/conda-bld/pytorch_1525796793591/work/torch/lib/THC/generic/THCTensor.c:23

I can't figure out what happened. Is the module code not same in train model? Why only encountered this problem during the test??

Can anyone help me ? Thanks

Shanmugavadivelugopal commented 5 years ago

I am having the same error,if you solved this please let me know.Thank you.

dukebrah commented 5 years ago

change:

transforms.GroupOverSample(net.input_size, net.scale_size),

to

transforms.GroupScale(net.scale_size), transforms.GroupCenterCrop(net.input_size),

Shanmugavadivelugopal commented 5 years ago

@dineshp Thank you.While training the model got the following error in main.py storing name: TRN_something_RGB_BNInception_TRN_segment8

 Initializing TSN with base model: BNInception.
    TSN Configurations:
        input_modality:     RGB
        num_segments:       8
        new_length:         1
        consensus_module:   TRN
        dropout_ratio:      0.8
        img_feature_dim:    256

/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py:514: UserWarning: src is not broadcastable to dst, but they have the same number of elements.  Falling back to deprecated pointwise behavior.
  own_state[name].copy_(param)
video number:0
/usr/local/lib/python3.6/dist-packages/torchvision/transforms/transforms.py:188: UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead.
  "please use transforms.Resize instead.")
video number:0
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 320, in <module>
    main()
  File "main.py", line 128, in main
    train(train_loader, model, criterion, optimizer, epoch, log_training)
  File "main.py", line 161, in train
    for i, (input, target) in enumerate(train_loader):
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 417, in __iter__
    return DataLoaderIter(self)
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 242, in __init__
    self._put_indices()
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 290, in _put_indices
    indices = next(self.sample_iter, None)
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/sampler.py", line 119, in __iter__
    for idx in self.sampler:
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/sampler.py", line 50, in __iter__
    return iter(torch.randperm(len(self.data_source)).long())
RuntimeError: invalid argument 1: must be strictly positive at /pytorch/torch/lib/TH/generic/THTensorMath.c:2247

is there any suggestions from you? Thanks in advance