Skip to content

尊敬的作者,你好! 附载的STANet模型为什么会出现pred和tar尺寸不匹配问题,总是相差64倍。 #44

@HZWXW371

Description

@HZWXW371

报错信息如下:
Traceback (most recent call last):
File "/first_disk/hongzheng/CDLab-master/src/train.py", line 59, in main
trainer.run()
File "/first_disk/hongzheng/CDLab-master/src/core/trainer.py", line 75, in run
self.train()
File "/first_disk/hongzheng/CDLab-master/src/core/trainer.py", line 96, in train
acc = self.evaluate_epoch(epoch=epoch)
File "/first_disk/hongzheng/CDLab-master/src/impl/trainers/cd_trainer.py", line 185, in evaluate_epoch
loss = self.criterion(pred, tar)
File "/home/ly/miniconda3/envs/hz/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
return self._call_impl(args, **kwargs)
File "/home/ly/miniconda3/envs/hz/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
return forward_call(args, **kwargs)
File "/first_disk/hongzheng/CDLab-master/src/utils/losses.py", line 100, in forward
loss = 0.5
torch.sum(utar
torch.pow(pred, 2)) / n_u +
RuntimeError: The size of tensor a (4) must match the size of tensor b (64) at non-singleton dimension 1

或者

Traceback (most recent call last):
File "/first_disk/hongzheng/STANet/./train.py", line 169, in
miou_current = val(opt, model)
File "/first_disk/hongzheng/STANet/./train.py", line 86, in val
score = model.test(val=True) # run inference
File "/first_disk/hongzheng/STANet/models/CDFA_model.py", line 79, in test
metrics.update(self.L.detach().cpu().numpy(), pred.detach().cpu().numpy())
File "/first_disk/hongzheng/STANet/util/metrics.py", line 121, in update
self.confusion_matrix += self.__fast_hist(lt.flatten(), lp.flatten())
File "/first_disk/hongzheng/STANet/util/metrics.py", line 108, in __fast_hist
hist = np.bincount(self.num_classes * label_gt[mask].astype(int) + label_pred[mask],
IndexError: boolean index did not match indexed array along dimension 0; dimension is 4194304 but corresponding boolean dimension is 65536

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions