Skip to content

jojosam90/GANs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

GANs (Generative Adversarial Networks)

Belong to set of algorithms named generative models. Belong to unsupervised learning.

image

Application : Text / Image / Video Generation , Text-to-image synthesis

image

General ideas

GANs consists of a pair of neural networks that fight with each other. One is called generator and another one is called discriminator.

image

Build the simplest GANs

image

Build the Discriminator

How to tell computer to differentiate between faces and non-faces?

-Faces: Top Left and Bottom Right have the big values(dark pixels) whereas the other two corners has small values(light pixels).

-Noisy : Any values fall inside (range 0 to 1).

image

Method : Add the two values correspoonding and subtract the values corresponding to other two corners.

image

For faces, the end result value is high and for non-faces, the end result value is low. Threshold = 1 More than 1: face. Less than 1 : no face.

image

image

image

Build the Generator

image

image

This is a good generator and able to generate the faces as the end value result is high and also the value for top left and bottom right are always big and the values for the corresponding value are smalls.

image

image

image

The training process : Backpropagation

image

First taking data point and perform forward pass, calculate prediction and calculate error based on log loss, take the derivative of the error based on all weight using chain rule to tell us how much to obtain each weight in order to best decrease the error (gradient descent). Plot the error and calculate gradient which is the direction of greatest growth and then take a tiny step in the direction of negative of this gradient in order to find new parameter that decrease error as much as possible.

image

image

Training the generator and discriminator

Set the random z value (between 0 and 1) as input to generator, do a forward pass to obtain some image which is probably face (generated image). Then pass generated images to discriminator to tell is fake or real. Discriminator output probability.

image

image

Since the number is random and not face and the image generated by generator, the discriminator should saying is fake (want Output 0). The generator want to generate an image so good so that discriminator classifies as real (want output 1). That both error function helps to train the neural network. The derivatives of both help to update weights of both neural network. The two error functions are fighting each other but is okay because red error function is changing the generator weigths and blue error functions is changing the discriminator weights therefore they dont coliide and simply improve both neural networks.

image

Running epochs

image

pick a random Z value > apply generator to produce fake image > apply image to discriminator > backpropagation to update weights on both generator and discriminator > take real image and plugin to discriminator and update weights again using backpropagation

image

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors