Code Monkey home page Code Monkey logo

Comments (10)

Phoenix-Shen avatar Phoenix-Shen commented on June 29, 2024

in_ch= 15#输入通道数 out_ch = 13#输出通道数 作者您好,我在运行train.py的时候出现了这个问题,然后我发现是在config.py中的通道数是不匹配的,不知道这个是怎么解决的,直接修改通道数吗还是有别的方式

嗯,是这样的,可以灵活改变config.py中的参数以应对您的情况。在印象中论文原文中输入通道应该是15。

from dsen2_cr_pytorch.

123eye avatar 123eye commented on June 29, 2024

是的,输入通道是15没错,当我改变输出通道为15时还是报一样的错误
cloud_img.shape torch.Size([1, 15, 256, 256])
ground_truth.shape torch.Size([1, 15, 256, 256])
csm_img.shape torch.Size([1, 1, 256, 256])
开始训练...
Traceback (most recent call last):
File "train.py", line 134, in
train(myconfig)
File "train.py", line 102, in train
img_fake = net(img_cld)
File "/root/miniconda3/envs/dsen/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "/root/autodl-tmp/dsen2_cr/models/DSen2_CR.py", line 46, in forward
return x[:,2:,:,:]+self.net(x)
RuntimeError: The size of tensor a (13) must match the size of tensor b (15) at non-singleton dimension 1

from dsen2_cr_pytorch.

Phoenix-Shen avatar Phoenix-Shen commented on June 29, 2024

是的,输入通道是15没错,当我改变输出通道为15时还是报一样的错误 cloud_img.shape torch.Size([1, 15, 256, 256]) ground_truth.shape torch.Size([1, 15, 256, 256]) csm_img.shape torch.Size([1, 1, 256, 256]) 开始训练... Traceback (most recent call last): File "train.py", line 134, in train(myconfig) File "train.py", line 102, in train img_fake = net(img_cld) File "/root/miniconda3/envs/dsen/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "/root/autodl-tmp/dsen2_cr/models/DSen2_CR.py", line 46, in forward return x[:,2:,:,:]+self.net(x) RuntimeError: The size of tensor a (13) must match the size of tensor b (15) at non-singleton dimension 1

如果输入通道是15,那么

  • x.shape = [batch_size, 15, height, width]
  • x[:,2:,:,:].shape = [batch_size, 13, height, width]

请你检查一下self.net(x)的输出是否是13通道?从报错信息上来看,net输出的是15通道。所以不能进行element-wise的加法。

from dsen2_cr_pytorch.

123eye avatar 123eye commented on June 29, 2024

x.shape torch.Size([1, 15, 256, 256])
self.net(x) torch.Size([1, 15, 256, 256])
x[:,2:,:,:] torch.Size([1, 13, 256, 256])
是的我输出来self.net(x)的输出是13通道,这个要怎么改

from dsen2_cr_pytorch.

Phoenix-Shen avatar Phoenix-Shen commented on June 29, 2024

x.shape torch.Size([1, 15, 256, 256]) self.net(x) torch.Size([1, 15, 256, 256]) x[:,2:,:,:] torch.Size([1, 13, 256, 256]) 是的我输出来self.net(x)的输出是13通道,这个要怎么改

config.py的第34行,out_ch = 13#输出通道数,这个out_ch应该是13的,你看看是不是误修改成15了。

from dsen2_cr_pytorch.

123eye avatar 123eye commented on June 29, 2024

是的 我只修改这一个地方,改成13也是报一样的错误

from dsen2_cr_pytorch.

123eye avatar 123eye commented on June 29, 2024

这就又回到了最初的问题
Traceback (most recent call last):
File "train.py", line 131, in
train(myconfig)
File "train.py", line 100, in train
loss= CARL_Loss(img_truth,img_csm,img_fake,img_cld)
File "/root/autodl-tmp/dsen2_cr/utils/img_operations.py", line 65, in carl_error
cscmae = t.mean(clearmask * t.abs(predicted - input_cloudy) + csm * t.abs(
RuntimeError: The size of tensor a (13) must match the size of tensor b (15) at non-singleton dimension 1

from dsen2_cr_pytorch.

Phoenix-Shen avatar Phoenix-Shen commented on June 29, 2024

这就又回到了最初的问题 Traceback (most recent call last): File "train.py", line 131, in train(myconfig) File "train.py", line 100, in train loss= CARL_Loss(img_truth,img_csm,img_fake,img_cld) File "/root/autodl-tmp/dsen2_cr/utils/img_operations.py", line 65, in carl_error cscmae = t.mean(clearmask * t.abs(predicted - input_cloudy) + csm * t.abs( RuntimeError: The size of tensor a (13) must match the size of tensor b (15) at non-singleton dimension 1

这个问题有人已经提出来了,很奇怪,在我之前用的时候并没有出问题,有可能是我上传了之前的版本到github

详情请看这里

from dsen2_cr_pytorch.

123eye avatar 123eye commented on June 29, 2024

loss= CARL_Loss(img_truth,img_csm,img_fake,img_cld)我在这个函数之前将img_cld拆分了一下,是对的吗

from dsen2_cr_pytorch.

Phoenix-Shen avatar Phoenix-Shen commented on June 29, 2024

loss= CARL_Loss(img_truth,img_csm,img_fake,img_cld)我在这个函数之前将img_cld拆分了一下,是对的吗

嗯,是对的。这几天比较忙回复不及时,不好意思哈。我目前没有条件运行代码,有任何问题欢迎在下面留言

from dsen2_cr_pytorch.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.