WGAN outputs only noises


I am doing a small experiment. I am trying to use WGAN example from lesson 7. I created my own dataset for this purpose. I am using the following code snippet, but the outputs for every epoch are the same, noises.

def get_data(bs, size):
    return (GANItemList.from_folder(path, noise_sz=100)
               .transform(tfms=[[crop_pad(size=size, row_pct=(0,1), col_pct=(0,1))], []], size=size, tfm_y=True)
               .normalize(stats = [torch.tensor([0.5,0.5,0.5]), torch.tensor([0.5,0.5,0.5])], do_x=False, do_y=True))

data = get_data(4, 64)

generator = basic_generator(in_size=64, n_channels=3, n_extra_layers=1)
critic    = basic_critic(in_size=64, n_channels=3, n_extra_layers=1)

learn = GANLearner.wgan(data, generator, critic, switch_eval=False, opt_func = partial(optim.Adam, betas = (0.,0.99)), wd=0.)




What do you think what could be the cause of these noises? Do I need to tweak some parameters? or create bigger dataset?

Any help would be greatly appreciated.

I solved by setting None to transformations:

.transform(tfms=None, size=size, tfm_y=True)

I am having this same issue. How large of a dataset did you build? @Mirodil

Dataset was not big around 1000(128x128) images.

not working for me, i dont know why

How many epochs did it take you/what batch size did you use? I’m having the same issue but only 125 images.

My code looks like:

def get_data(bs, size):
return (GANItemList.from_folder(path, noise_sz=1000)
.transform(tfms=None, size=size)
.normalize(stats = [torch.tensor([0.5,0.5,0.5]), torch.tensor([0.5,0.5,0.5])], do_x=False, do_y=False))

data = get_data(20, 512)

As I ran it in CPU I had to use small batch size 4 images of 32x32 size, and I ran 10 epoch to see something else then noises.

It seems like this is a classic issue with GANs related to the generator loss not decreasing. I increased the learning rate and it’s working a bit better now.


Thanks Petulla this also worked for me!

I am using around 4000 images, i doubled the learning rate from 2e-4 to 2e-2 and it went from noise to something more interesting :slight_smile: