imatif17 / Prototype-Mean-Teacher

16 stars 1 forks source link

<IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)> #10

Closed judyxt closed 1 month ago

judyxt commented 1 month ago

Hello! I met the <IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)> when I tried on BDD10k datasets(Daytime/Night/Dusk) ,it encounted on rcnn.py-->

loss_D_img_s = criterion(D_img_out_s, torch.FloatTensor(D_img_outs.data.size()).fill(source_label).to(self.device))/1000.0

It looks like a problem with the cross-entropy calculation. How can I solve it?

Traceback (most recent call last): File "train_net.py", line 58, in <module> launch( File "/root/miniconda3/envs/pmt/lib/python3.8/site-packages/detectron2/engine/launch.py", line 84, in launch main_func(*args) File "train_net.py", line 52, in main return trainer.train() File "/root/data1/judy/Prototype-Mean-Teacher/pmteacher/engine/trainer.py", line 179, in train self.train_loop(self.start_iter, self.max_iter) File "/root/data1/judy/Prototype-Mean-Teacher/pmteacher/engine/trainer.py", line 194, in train_loop self.run_step_full_semisup() File "/root/data1/judy/Prototype-Mean-Teacher/pmteacher/engine/trainer.py", line 320, in run_step_full_semisup record_dict, _, _, _ = self.model( File "/root/miniconda3/envs/pmt/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, **kwargs) File "/root/data1/judy/Prototype-Mean-Teacher/pmteacher/modeling/meta_arch/rcnn.py", line 424, in forward loss_D_img_s = criterion(D_img_out_s, torch.FloatTensor(D_img_out_s.data.size()).fill_(source_label).to(self.device))/1000.0 File "/root/miniconda3/envs/pmt/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, **kwargs) File "/root/miniconda3/envs/pmt/lib/python3.8/site-packages/torch/nn/modules/loss.py", line 1120, in forward return F.cross_entropy(input, target, weight=self.weight, File "/root/miniconda3/envs/pmt/lib/python3.8/site-packages/torch/nn/functional.py", line 2824, in cross_entropy return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index) IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)