Skip to content
New issue

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

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

Already on GitHub? # to your account

RuntimeError: Given input size: (576x27x27). Calculated output size: (576x-1x-1). Output size is too small #11

Open
Lily1992 opened this issue Oct 31, 2019 · 7 comments

Comments

@Lily1992
Copy link

I got the error when i use the model of mobilenetv3_small to train,and i used my own dataset like as VOC. Would you give me some advice?
And,would you tell me the torch version and torchvision version?

@aviaisr
Copy link

aviaisr commented Jan 6, 2020

I'm having the same issue. Were you able to overcome that?

@Strand2013
Copy link

Maybe you need to modify here, mobilenetv3_seg.py script
around 60 line

class _LRASPP(nn.Module):
"""Lite R-ASPP"""

def __init__(self, in_channels, norm_layer, **kwargs):
    super(_LRASPP, self).__init__()
    out_channels = 128
    self.b0 = nn.Sequential(
        nn.Conv2d(in_channels, out_channels, 1, bias=False),
        norm_layer(out_channels),
        nn.ReLU(True)
    )
    self.b1 = nn.Sequential(
        nn.AdaptiveAvgPool2d((8, 8)),  
        # nn.AvgPool2d(kernel_size=(49, 49), stride=(16, 20)),  # check it
        nn.Conv2d(in_channels, out_channels, 1, bias=False),
        nn.Sigmoid(),
    )

@aviaisr
Copy link

aviaisr commented Jan 22, 2020

@raysue Thanks! This has fixed the issue!

@eeyrw
Copy link

eeyrw commented Feb 28, 2020

I encountered same error and have no idea why and modify it according @raysue then it works.

@sungh66
Copy link

sungh66 commented Oct 13, 2022

When i exported onnx model, onnx cannot surpport adaptive_avg_pool2d.How can i fix the problem?

@Strand2013
Copy link

When i exported onnx model, onnx cannot surpport adaptive_avg_pool2d.How can i fix the problem?

upgrade your onnx version, use opset=13 or fix your input size use nn.AvgPool2d with suitable parameters : kernel_size and stride

@Prashant-THRSL
Copy link

Replace this line:
nn.AvgPool2d(kernel_size=(49, 49), stride=(16, 20)),
with:
nn.AdaptiveAvgPool2d(output_size=(1, 1)),
in mobilenetv3_seg.py file

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

No branches or pull requests

6 participants