Eric-is-good / VIT_wganGP

VITGAN 一个结合了 vision transformer 和 wgangp 的对抗生成网络,生成动漫头像,同时提供一个传统卷积网络的训练好的模型,仅仅 20 M.
10 stars 1 forks source link

出现报错RuntimeError: mat1 and mat2 shapes cannot be multiplied (57x215296 and 256x100),不知道是什么问题,向您请教。 #1

Open langer-zheng opened 2 years ago

langer-zheng commented 2 years ago

您好,感谢您分享的代码! 我在使用自己的训练集运行的时候,出现一下问题,请教您如何解决,谢谢。 100%|██████████| 57/57 [00:00<00:00, 491.31it/s] 0%| | 0/100 [00:00<?, ?it/s] Traceback (most recent call last):

File "C:\code\WGAN_GP\train_for_vae.py", line 367, in trainer.train(num_epochs=100,

File "C:\code\WGAN_GP\train_for_vae.py", line 151, in train recon_loss, kl_diverge = self.compute_batch(batch)

File "C:\code\WGAN_GP\train_for_vae.py", line 196, in compute_batch outputs, mu, log_var = self.model(images)

File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl return forward_call(*input, **kwargs)

File "C:\code\WGAN_GP\train_for_vae.py", line 88, in forward mu, log_var = self.encoder(x)

File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl return forward_call(*input, **kwargs)

File "C:\code\WGAN_GP\model\vaemodel.py", line 99, in forward mu, log_var = self.mu(outputs), self.log_var(outputs)

File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl return forward_call(*input, **kwargs)

File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\linear.py", line 103, in forward return F.linear(input, self.weight, self.bias)

RuntimeError: mat1 and mat2 shapes cannot be multiplied (57x215296 and 256x100)

Eric-is-good commented 2 years ago

可能的问题 1.如果你直接下载本代码,那么默认vae是可以用的,图片大小必须为 64 64 2.你的报错显示 57x215296 ,215296 = 464 464,所以我猜测你使用的不是 64 64 的图片,你可能用的 464 464 的图片 3.请使用 utils.py 的 read_path 来转换图片大小