Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

调试main_cd.py中出现ValueError: size shape must match input shape. Input is 2D, size is 4 #1

Open
huangbo20 opened this issue Nov 15, 2022 · 1 comment

Comments

@huangbo20
Copy link

作者您好,您的论文和代码工作相当出色,当我在调试代码过程中遇到了问题,需要您的指点,希望您能回复我的问题,非常感谢
Traceback (most recent call last):
File "/home/huangbo/CD_Code/2022-RS-EGCTNet/EGCTNet_pytorch-main/main_cd.py", line 83, in
train(args)
File "/home/huangbo/CD_Code/2022-RS-EGCTNet/EGCTNet_pytorch-main/main_cd.py", line 14, in train
model.train_models()
File "/home/huangbo/CD_Code/2022-RS-EGCTNet/EGCTNet_pytorch-main/models/trainer.py", line 342, in train_models
self._backward_G()
File "/home/huangbo/CD_Code/2022-RS-EGCTNet/EGCTNet_pytorch-main/models/trainer.py", line 315, in _backward_G
self.G_loss = self._pxl_loss(self.G_pred[-1], gt, self.G_pred[-2], gt_edge)
File "/home/huangbo/anaconda3/envs/pytorch1.8/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/huangbo/CD_Code/2022-RS-EGCTNet/EGCTNet_pytorch-main/models/losses.py", line 278, in forward
loss_c = cross_entropy(inputs, target)
File "/home/huangbo/CD_Code/2022-RS-EGCTNet/EGCTNet_pytorch-main/models/losses.py", line 19, in cross_entropy
input = F.interpolate(input, size=target.shape[1:], mode='bilinear',align_corners=True)
File "/home/huangbo/anaconda3/envs/pytorch1.8/lib/python3.8/site-packages/torch/nn/functional.py", line 3472, in interpolate
raise ValueError(
ValueError: size shape must match input shape. Input is 2D, size is 4

@chen11221
Copy link
Owner

您好,根据您上述的信息,我推测可能是数据的问题,您可以检查一下数据是否正确。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants