da-faster-rcnn-PyTorch icon indicating copy to clipboard operation
da-faster-rcnn-PyTorch copied to clipboard

problem about dataparallel

Open codingwolfman opened this issue 5 years ago • 2 comments

when i set batchsize=1, everything is ok, but when i turn to batchsize=2, i meet error Traceback (most recent call last): File "da_trainval_net.py", line 393, in tgt_im_data, tgt_im_info, tgt_gt_boxes, tgt_num_boxes, tgt_need_backprop) File "/home/wzy/anaconda3/envs/pytorch0.4/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in call result = self.forward(*input, **kwargs) File "/home/wzy/anaconda3/envs/pytorch0.4/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 115, in forward return self.gather(outputs, self.output_device) File "/home/wzy/anaconda3/envs/pytorch0.4/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 127, in gather return gather(outputs, output_device, dim=self.dim) File "/home/wzy/anaconda3/envs/pytorch0.4/lib/python3.6/site-packages/torch/nn/parallel/scatter_gather.py", line 68, in gather return gather_map(outputs) File "/home/wzy/anaconda3/envs/pytorch0.4/lib/python3.6/site-packages/torch/nn/parallel/scatter_gather.py", line 63, in gather_map return type(out)(map(gather_map, zip(*outputs))) File "/home/wzy/anaconda3/envs/pytorch0.4/lib/python3.6/site-packages/torch/nn/parallel/scatter_gather.py", line 55, in gather_map return Gather.apply(target_device, dim, *outputs) File "/home/wzy/anaconda3/envs/pytorch0.4/lib/python3.6/site-packages/torch/nn/parallel/_functions.py", line 54, in forward ctx.input_sizes = tuple(map(lambda i: i.size(ctx.dim), inputs)) File "/home/wzy/anaconda3/envs/pytorch0.4/lib/python3.6/site-packages/torch/nn/parallel/_functions.py", line 54, in ctx.input_sizes = tuple(map(lambda i: i.size(ctx.dim), inputs)) RuntimeError: dimension specified as 0 but tensor has no dimensions

codingwolfman avatar Jun 26 '19 13:06 codingwolfman

same error talked here https://github.com/jwyang/faster-rcnn.pytorch/issues/226#issuecomment-402459343 but i'm not sure about DA_loss

stormchasingg avatar Aug 01 '19 08:08 stormchasingg

i just fixed by adding rpn_loss_cls = torch.unsqueeze(rpn_loss_cls, 0) rpn_loss_bbox = torch.unsqueeze(rpn_loss_bbox, 0) RCNN_loss_cls = torch.unsqueeze(RCNN_loss_cls, 0) RCNN_loss_bbox = torch.unsqueeze(RCNN_loss_bbox, 0) DA_img_loss_cls = torch.unsqueeze(DA_img_loss_cls, 0) DA_ins_loss_cls = torch.unsqueeze(DA_ins_loss_cls, 0) tgt_DA_img_loss_cls = torch.unsqueeze(tgt_DA_img_loss_cls, 0) tgt_DA_ins_loss_cls = torch.unsqueeze(tgt_DA_ins_loss_cls, 0) DA_cst_loss = torch.unsqueeze(DA_cst_loss, 0) tgt_DA_cst_loss = torch.unsqueeze(tgt_DA_cst_loss, 0) before return rois, cls_prob, bbox_pred, rpn_loss_cls, rpn_loss_bbox, RCNN_loss_cls, RCNN_loss_bbox, rois_label, DA_img_loss_cls, DA_ins_loss_cls, tgt_DA_img_loss_cls, tgt_DA_ins_loss_cls, DA_cst_loss, tgt_DA_cst_loss

stormchasingg avatar Aug 05 '19 06:08 stormchasingg