Python 3.x Pytorch摘要仅适用于U-Net的一种特定输入大小
我正在尝试在Pytorch中实现该功能。当我使用Python 3.x Pytorch摘要仅适用于U-Net的一种特定输入大小,python-3.x,multidimensional-array,deep-learning,pytorch,conv-neural-network,Python 3.x,Multidimensional Array,Deep Learning,Pytorch,Conv Neural Network,我正在尝试在Pytorch中实现该功能。当我使用print(model)打印模型时,我得到了正确的体系结构: 但当我尝试使用(或任何其他输入大小)打印摘要时: 我得到一个错误: RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 70 and 71 in dimension 2 at /Users/distiller/project/conda/conda-bld/py
print(model)
打印模型时,我得到了正确的体系结构:
但当我尝试使用(或任何其他输入大小)打印摘要时:
我得到一个错误:
RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 70 and 71 in dimension 2 at /Users/distiller/project/conda/conda-bld/pytorch_1579022061893/work/aten/src/TH/generic/THTensor.cpp:612
但是,如果我将输入大小设置为input\u size=(3224224))
(就像对这个人有效一样),那么它就可以完美地工作。我很困惑
有人能帮我吗?怎么了
编辑:我使用了中的模型体系结构。您提供的
UNet
体系结构不支持该形状(除非深度参数为,否则请提供您的u-net模块的定义。听起来您已经完成了u-net的自定义实现?如果您不提供模型定义,没有人可以告诉您任何确定的信息。@jodag谢谢。我正在编辑答案,以提供我使用模型定义的链接。谢谢。这是我的建议。)我很有帮助。当我得到这个回复时,我也得到了一些解释:基本上和你说的一样。不过你的解释更详细。谢谢你。
RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 70 and 71 in dimension 2 at /Users/distiller/project/conda/conda-bld/pytorch_1579022061893/work/aten/src/TH/generic/THTensor.cpp:612
>> torch.nn.functional.max_pool2d(torch.zeros(1, 1, 10, 10), 2).shape
torch.Size([1, 1, 5, 5])
>> torch.nn.functional.max_pool2d(torch.zeros(1, 1, 11, 11), 2).shape
torch.Size([1, 1, 5, 5])