znxlwm / pytorch-generative-model-collections

Collection of generative models in Pytorch version.
2.59k stars 546 forks source link

Size issue from running custom dataset #25

Open evdelph opened 4 years ago

evdelph commented 4 years ago

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 Dreal = 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 commented 1 year ago

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 Dreal = 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 ?