zhanghang1989 / zhanghang1989/PyTorch-Encoding
operands could not be broadcast together with shapes (8,256) (4,256,256)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2k
- Forks
- 448
- PR merge metrics
- No merged PRs in 30d
Description
hello,When I run,:python train.py --dataset pcontext --model deeplab --aux --backbone resnest200
I found the following error:
File "/dahuafs/userdata/229288/00_deeplearning/01_pytorch/segEncoding/experiments/segmentation/train.py", line 238, in validation
correct, labeled, inter, union = eval_batch(self.model, image, target)
File "/dahuafs/userdata/229288/00_deeplearning/01_pytorch/segEncoding/experiments/segmentation/train.py", line 229, in eval_batch
inter, union = utils.batch_intersection_union(pred.data, target, self.nclass)
File "/dahuafs/userdata/229288/00_deeplearning/anaconda3/envs/scseg/lib/python3.7/site-packages/torch_encoding-1.2.2b20201023-py3.7-linux-x86_64.egg/encoding/utils/metrics.py", line 122, in batch_intersection_union
predict = predict * (target > 0).astype(predict.dtype)
ValueError: operands could not be broadcast together with shapes (8,256) (4,256,256)
def eval_batch(model, image, target):
outputs = model(image)
outputs = gather(outputs, 0, dim=0)
pred = outputs[0]
target = target.cuda()
correct, labeled = utils.batch_pix_accuracy(pred.data, target)
inter, union = utils.batch_intersection_union(pred.data, target, self.nclass)
return correct, labeled, inter, union
Is there something wrong with this code?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduced command and inspect validation/eval_batch in experiments/segmentation/train.py, then follow batch_intersection_union in encoding/utils/metrics.py. Compare the prediction and target shapes at the failing call and determine why validation passes incompatible inputs; done means the pcontext run completes this metric step without the broadcasting error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- computer-vision, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100