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

Size issue from running custom dataset #25

Open
evdelph opened this issue Feb 10, 2020 · 1 comment
Open

Size issue from running custom dataset #25

evdelph opened this issue Feb 10, 2020 · 1 comment

Comments

@evdelph
Copy link

evdelph commented Feb 10, 2020

Hello,
I followed the instructions for uploading a custom dataset. However, I get this error:

$ python main.py --dataset ships --gan_type GAN --epoch 50 --batch_size 64
---------- Networks architecture -------------
generator(
(fc): Sequential(
(0): Linear(in_features=62, out_features=1024, bias=True)
(1): BatchNorm1d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU()
(3): Linear(in_features=1024, out_features=6272, bias=True)
(4): BatchNorm1d(6272, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(5): ReLU()
)
(deconv): Sequential(
(0): ConvTranspose2d(128, 64, kernel_size=(4, 4), stride=(2, 2), padding=(1, 1))
(1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU()
(3): ConvTranspose2d(64, 3, kernel_size=(4, 4), stride=(2, 2), padding=(1, 1))
(4): Tanh()
)
)
Total number of parameters: 6642243
discriminator(
(conv): Sequential(
(0): Conv2d(3, 64, kernel_size=(4, 4), stride=(2, 2), padding=(1, 1))
(1): LeakyReLU(negative_slope=0.2)
(2): Conv2d(64, 128, kernel_size=(4, 4), stride=(2, 2), padding=(1, 1))
(3): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(4): LeakyReLU(negative_slope=0.2)
)
(fc): Sequential(
(0): Linear(in_features=6272, out_features=1024, bias=True)
(1): BatchNorm1d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): LeakyReLU(negative_slope=0.2)
(3): Linear(in_features=1024, out_features=1, bias=True)
(4): Sigmoid()
)
)
Total number of parameters: 6561217

training start!!
Traceback (most recent call last):
File "main.py", line 111, in
main()
File "main.py", line 103, in main
gan.train()
File "C:\Users\evdelph\Desktop\NEEC\test\pytorch-generative-model-collections\GAN.py", line 144, in train
D_real = self.D(x_)
File "C:\Users\evdelph\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\nn\modules\module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "C:\Users\evdelph\Desktop\NEEC\test\pytorch-generative-model-collections\GAN.py", line 67, in forward
x = x.view(-1, 128 * (self.input_size // 4) * (self.input_size // 4))
RuntimeError: shape '[-1, 6272]' is invalid for input of size 3276800

I am not sure how to fix this error. I am trying to generate images of ships for a school project.

Any insight would be great. Thanks!

@abujbr
Copy link

abujbr commented Jun 16, 2023

Hello, I followed the instructions for uploading a custom dataset. However, I get this error:

$ python main.py --dataset ships --gan_type GAN --epoch 50 --batch_size 64

---------- Networks architecture -------------
generator(
(fc): Sequential(
(0): Linear(in_features=62, out_features=1024, bias=True)
(1): BatchNorm1d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU()
(3): Linear(in_features=1024, out_features=6272, bias=True)
(4): BatchNorm1d(6272, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(5): ReLU()
)
(deconv): Sequential(
(0): ConvTranspose2d(128, 64, kernel_size=(4, 4), stride=(2, 2), padding=(1, 1))
(1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU()
(3): ConvTranspose2d(64, 3, kernel_size=(4, 4), stride=(2, 2), padding=(1, 1))
(4): Tanh()
)
)
Total number of parameters: 6642243
discriminator(
(conv): Sequential(
(0): Conv2d(3, 64, kernel_size=(4, 4), stride=(2, 2), padding=(1, 1))
(1): LeakyReLU(negative_slope=0.2)
(2): Conv2d(64, 128, kernel_size=(4, 4), stride=(2, 2), padding=(1, 1))
(3): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(4): LeakyReLU(negative_slope=0.2)
)
(fc): Sequential(
(0): Linear(in_features=6272, out_features=1024, bias=True)
(1): BatchNorm1d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): LeakyReLU(negative_slope=0.2)
(3): Linear(in_features=1024, out_features=1, bias=True)
(4): Sigmoid()
)
)
Total number of parameters: 6561217
training start!! Traceback (most recent call last): File "main.py", line 111, in main() File "main.py", line 103, in main gan.train() File "C:\Users\evdelph\Desktop\NEEC\test\pytorch-generative-model-collections\GAN.py", line 144, in train D_real = self.D(x_) File "C:\Users\evdelph\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\nn\modules\module.py", line 532, in call result = self.forward(*input, **kwargs) File "C:\Users\evdelph\Desktop\NEEC\test\pytorch-generative-model-collections\GAN.py", line 67, in forward x = x.view(-1, 128 * (self.input_size // 4) * (self.input_size // 4)) RuntimeError: shape '[-1, 6272]' is invalid for input of size 3276800

I am not sure how to fix this error. I am trying to generate images of ships for a school project.

Any insight would be great. Thanks!

I got exactly the same error message!

did you managed to solve it ?

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