Scintillare / AIGan

Attack-Inspired GAN - unofficial pytorch implementation
17 stars 4 forks source link

The main file is faulty #2

Open SuperCarryFu opened 2 years ago

SuperCarryFu commented 2 years ago

CUDA Available: True Traceback (most recent call last): File "E:/PythonCode/AIGan/main.py", line 52, in aiGAN.train(dataloader, epochs) File "E:\PythonCode\AIGan\AIGAN.py", line 284, in train self.train_batch(images, labels) File "E:\PythonCode\AIGan\AIGAN.py", line 165, in train_batch d_real_logits, d_real_probs = self.netDisc(pgd_images) File "D:\Miniconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl return forward_call(*input, kwargs) File "E:\PythonCode\AIGan\models.py", line 77, in forward output = self.model(x).squeeze() File "D:\Miniconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl return forward_call(*input, *kwargs) File "D:\Miniconda3\envs\pytorch\lib\site-packages\torch\nn\modules\container.py", line 141, in forward input = module(input) File "D:\Miniconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl return forward_call(input, kwargs) File "D:\Miniconda3\envs\pytorch\lib\site-packages\torch\nn\modules\instancenorm.py", line 57, in forward return F.instance_norm( File "D:\Miniconda3\envs\pytorch\lib\site-packages\torch\nn\functional.py", line 2326, in instance_norm _verify_spatial_size(input.size()) File "D:\Miniconda3\envs\pytorch\lib\site-packages\torch\nn\functional.py", line 2293, in _verify_spatial_size raise ValueError("Expected more than 1 spatial element when training, got input size {}".format(size)) ValueError: Expected more than 1 spatial element when training, got input size torch.Size([128, 32, 1, 1])

SuperCarryFu commented 2 years ago

What should I do?

Scintillare commented 2 years ago

Hi. As I see, there is a problem with the input size of your images. You should use sizes compatible with the model architecture. I hope the problem has been solved.

SuperCarryFu commented 2 years ago

The issue has been resolved, thank you for your reply

wowowowole commented 1 year ago

How did you solve this problem? I also encountered the same problem

wowowowole commented 1 year ago

The issue has been resolved, thank you for your reply

How did you solve this problem? I also encountered the same problem

Scintillare commented 1 year ago

Hi, @wowowowole . Please, provide your output from the console with the error

wowowowole commented 1 year ago

Traceback (most recent call last): File "F:\sitepy\pycharm\AIGan-main\main.py", line 52, in aiGAN.train(dataloader, epochs) File "F:\sitepy\pycharm\AIGan-main\AIGAN.py", line 292, in train self.train_batch(images, labels) File "F:\sitepy\pycharm\AIGan-main\AIGAN.py", line 173, in train_batch d_real_logits, d_real_probs = self.netDisc(pgd_images) File "F:\software download\Anaconda3\envs\PyTorch\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl return forward_call(*input, kwargs) File "F:\sitepy\pycharm\AIGan-main\models.py", line 77, in forward output = self.model(x).squeeze() File "F:\software download\Anaconda3\envs\PyTorch\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl return forward_call(*input, *kwargs) File "F:\software download\Anaconda3\envs\PyTorch\lib\site-packages\torch\nn\modules\container.py", line 141, in forward input = module(input) File "F:\software download\Anaconda3\envs\PyTorch\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl return forward_call(input, kwargs) File "F:\software download\Anaconda3\envs\PyTorch\lib\site-packages\torch\nn\modules\instancenorm.py", line 57, in forward return F.instance_norm( File "F:\software download\Anaconda3\envs\PyTorch\lib\site-packages\torch\nn\functional.py", line 2326, in instance_norm _verify_spatial_size(input.size()) File "F:\software download\Anaconda3\envs\PyTorch\lib\site-packages\torch\nn\functional.py", line 2293, in _verify_spatial_size raise ValueError("Expected more than 1 spatial element when training, got input size {}".format(size)) ValueError: Expected more than 1 spatial element when training, got input size torch.Size([128, 32, 1, 1])

Process finished with exit code 1

1392081456 commented 7 months ago

The issue has been resolved, thank you for your reply

54/5000 Hello, I have the same problem when I directly use MNIST_target_model.pth, how do you solve it? Thank you!

bieyl commented 5 months ago

@SuperCarryFu Could you tell me how you solve the problem ValueError: Expected more than 1 spatial element when training, got input size torch.Size([128, 32, 1, 1])

bieyl commented 4 months ago

@Scintillare @SuperCarryFu Could you tell me how you solve the problem ValueError: Expected more than 1 spatial element when training, got input size torch.Size([128, 32, 1, 1]). I really want to known how to solve it for me as beginner. Thanks!