Lecture 6: Image Generation using Generative Adversarial Networks (GANs)

Session Recordings
English: https://youtu.be/79IvwU3G5_Q
Hindi: https://youtu.be/87xD5NEmLhA

In this lesson, we apply the techniques covered in previous lessons for generating images for anime faces using Generative Adversarial Networks or GANs. Notebooks used in this tutorial:

Asking/Answering Questions :
Reply to this thread to ask questions. Before asking, scroll through the thread and check if your question (or a similar one) is already present. If yes, just like it. We will give priority to the questions with the most likes. The rest will be answered by our mentors or the community. If you see a question you know the answer to, please post your answer as a reply to that question. Let’s help each other learn!

No lecture today? Am I missing something?

What are the business use cases for GANs, animeface generation seems to be a fun exercise :slight_smile:


It was postponed to 2nd January due to the holidays, hope you didn’t miss our email and were able to attend it :v:


please are we writing stats = (0.5, 0.5, 0.5), (0.5, 0.5, 0.5) because we have 3 channels and we want the mean and the standart deviation in each channel to be equal to 0.5?

Also, I didn’t really understand what T.CenterCrop(image_size) do exactly?
And what *stats means here : T.Normalize(*stats) ?

Also, I didn’t understand why the implementation of this function is like that ?
def denorm(img_tensors):
return img_tensors * stats[1][0] + stats[0][0]

Thank you !

1 Like

Does anyone get zero std value error from T.Normalize()? Did not find solutions on stackoverflow jet. I could write my custom normalization function, but want to know what is happening, is the reason any type conversion? Here is the log:
/usr/local/lib/python3.7/dist-packages/torchvision/transforms/functional.py in normalize(tensor, mean, std, inplace)
344 std = torch.as_tensor(std, dtype=dtype, device=tensor.device)
345 if (std == 0).any():
→ 346 raise ValueError(‘std evaluated to zero after conversion to {}, leading to division by zero.’.format(dtype))
347 if mean.ndim == 1:
348 mean = mean.view(-1, 1, 1)

ValueError: std evaluated to zero after conversion to torch.float32, leading to division by zero.

Just wanted to let you know what was happening, it may help you later:

It appeares that, problem was created by defining stat = (0.5, 0.5, 0.5),(0.5, 0.5, 0.5) outside Normalize(stat). It is weird as Python does not restrict that. I do not exactly know whether it is problem of pytorch or the problem of google colab, as my verry old laptop does allow me to use only colab. Also only way to clear the failure appeared to be termination of session from colab → runtime → manage sessions , othervise crush persists. And I lost whole day figuring it out :confused: