# GANs inputs normalized and generator only outputs in [-1; 1]

I'm currently coding a GAN on the dataset MNIST. I'm using the following code to transform my data:

# MNIST Dataset
transform = transforms.Compose([
transforms.ToTensor(),
transforms.Normalize((0.1307,), (0.3081,))])
# the output of torchvision datasets are PILImage images of range [0, 1] and we
# want data that is centered around 0 with a std of 1 (0.1307 and 0.3081 are the estimated values of the MNIST mean & std)


I will have data centered around 0 with a standard deviation of 1 ((0.1307,), (0.3081,) are the estimated mean & standard deviation on the training dataset)). So that means that there will occasionnaly be values above 1 and below -1 in the real data.

Now, my generator ends up with a tanh activation function:

return torch.tanh(self.fc4(x))  # outputs in[-1; 1]


That means there will never be values above 1 and below -1 in the faked data.

Is it possible that the discriminator picks on this phenomenon? This seems to be the case as its loss goes to 0 really quickly. However this also could also be the case that the discriminator is just "too strong" as I've seen numerous times on stackexchange posts. I however never seen nobody talking about the fact that it could pick on the fact that there are outliers in the "real data" and only pixels between -1 and 1 in the "fake data".

EDIT: the entirety of my code can be found here: https://github.com/JQuentinMendoza2008/PyTorch_GAN_for_MNIST_Dataset

Any suggestion is welcomed.

It's not just possible, it's a certainty. The generator should learn to translate an input distribution A to an output distribution B, if distribution B has range $$(-\infty, \infty)$$ and your generator can output only values in range $$(-1, 1)$$ the translation between the two simply can't happen.
• the min max normalization is actually probably the simplest one among normalizations. You just subtract the minimum value of the whole image to all pixels, and divide them by (max value of whole image - min value of whole image). The first step push down the min value to zero, the second step push down the max value to 1, so your guarantee to have values within the range $(0,1)$ (hence the necessity of using sigmoid activation with this normalization) Mar 29 at 8:05