SN-GAN
SN-GAN copied to clipboard
small bug in snres_generator.py
1 .For python3, tngf /= 2 gives float rather than int. This end up with a error:
TypeError: torch.FloatTensor constructor received an invalid combination of arguments
It can be simply avoided by using // operator
- Currently res generator only works for nlayers=4. Can be corrected by replacing ngf * 16 with 2 ** nlayers * ngf
Hi, @xinario @godisboy @Jiaming-Liu
I changed your fix suggestion, but I met this error:
oem@sgi:~/SN-GAN$ python3 train-res.py --cuda --dataPath celebJapan/
Namespace(batchsize=32, cuda=True, dataPath='celebJapan/', gpu_ids=[0, 1, 2, 3], manualSeed=None, n_dis=1, nz=128)
/usr/local/lib/python3.6/dist-packages/torchvision/transforms/transforms.py:188: UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead.
"please use transforms.Resize instead.")
Random Seed: 8018
Traceback (most recent call last):
File "train-res.py", line 71, in
- (torch.device device)
- (torch.Storage storage)
- (Tensor other)
- (tuple of ints size, torch.device device)
- (object data, torch.device device)
What's wrong with me??
Thanks in advance.
from @bemoregt.
The make_model
funtion of SNResGenerator
should be changed as:
def make_model(self, ngf, nlayers):
model = []
tngf = ngf*16
for i in range(nlayers):
model += [ResBlock(int(tngf), int(tngf/2), upsample=True)] # 8, 16, 32, 64
tngf /= 2
model += [nn.BatchNorm2d(ngf)]
model += [nn.ReLU()]
model += [nn.Conv2d(ngf, 3, kernel_size=3, stride=1, padding=1)]
model += [nn.Tanh()]
return nn.Sequential(*model)