Bohao-Lee / CME

65 stars 15 forks source link

RuntimeError: stack expects each tensor to be equal size, but got [3, 512, 512] at entry 0 and [3, 320, 320] at entry 4 #16

Open zzzzjx opened 2 years ago

zzzzjx commented 2 years ago

Thanks for your porject and it's very helpful to me, but when I run the finetune part, it occured RuntimeError: stack expects each tensor to be equal size, but got [3, 512, 512] at entry 0 and [3, 320, 320] at entry 4. I set the height and width to 512. What should I do to solve this problem, waiting for your reply. all the traceback is forward: Traceback (most recent call last): File "tool/train_decoupling_disturbance.py", line 405, in train(epoch,repeat_time,mask_ratio) File "tool/train_decoupling_disturbance.py", line 242, in train for batch_idx, (data, target) in enumerate(train_loader): File "/home/zjx/anaconda3/envs/py38/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 517, in next data = self._next_data() File "/home/zjx/anaconda3/envs/py38/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1179, in _next_data return self._process_data(data) File "/home/zjx/anaconda3/envs/py38/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1225, in _process_data data.reraise() File "/home/zjx/anaconda3/envs/py38/lib/python3.8/site-packages/torch/_utils.py", line 429, in reraise raise self.exc_type(msg) RuntimeError: Caught RuntimeError in DataLoader worker process 5. Original Traceback (most recent call last): File "/home/zjx/anaconda3/envs/py38/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 202, in _worker_loop data = fetcher.fetch(index) File "/home/zjx/anaconda3/envs/py38/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 47, in fetch return self.collate_fn(data) File "/home/zjx/anaconda3/envs/py38/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 83, in default_collate return [default_collate(samples) for samples in transposed] File "/home/zjx/anaconda3/envs/py38/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 83, in return [default_collate(samples) for samples in transposed] File "/home/zjx/anaconda3/envs/py38/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 55, in default_collate return torch.stack(batch, 0, out=out) RuntimeError: stack expects each tensor to be equal size, but got [3, 512, 512] at entry 0 and [3, 320, 320] at entry 4