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

RuntimeError: Given input size: (384x40x42). Calculated output size: (384x0x1). Output size is too small #12

Open
Kao404 opened this issue May 12, 2024 · 4 comments

Comments

@Kao404
Copy link

Kao404 commented May 12, 2024

Dear blogger, after training an epoch, there is an error, what is the reason and how to solve it?

@mkang315
Copy link
Owner

The spatial size of your input images is too small for any YOLO model. You could try to resize the images to the original input size (640x640) of our model or modify our code to create a custom model suitable for your image size.

@lanhuiling01
Copy link

The spatial size of your input images is too small for any YOLO model. You could try to resize the images to the original input size (640x640) of our model or modify our code to create a custom model suitable for your image size.输入图像的空间大小对于任何 YOLO 模型来说都太小。您可以尝试将图像大小调整为我们模型的原始输入大小 (640x640),或修改我们的代码以创建适合您的图像大小的自定义模型。

Why does the code report this error when testing the test set after training? When I fixed the picture to 640, the error was still reported, please help me

@mkang315
Copy link
Owner

This reported error occurs when kernel_size is bigger than its input_size in nn.AvgPool2d() or nn.MaxPool2d() function. The reason is when using ceil_mode=True, maxpool might return a dimension of 2 instead of 1, causing dimension mismatch. Switched to using ceil_mode=False or torch.max.

References:
https://discuss.pytorch.org/t/given-input-size-512x1x1-calculated-output-size-512x0x0-output-size-is-too-small/111071
https://github.com/leehanchung/cs224n/tree/2a4af4f556f361fc5c953bfe3f57c1b7c01a0da4/a5_public
pytorch/pytorch#28625 (comment)
pytorch/pytorch#26610 (comment)

@hahahaa1
Copy link

hahahaa1 commented Aug 2, 2024

In the code, the default value of ceil_mode is already false. I don't know how to solve this error. How should I make the modification?

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

4 participants