Merge pull request #68 from CinnamonXI/main

Lesson 10
This commit is contained in:
Jen Looper 2022-05-04 09:58:43 -04:00 committed by GitHub
commit cc23d758f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 161 additions and 7 deletions

View File

@ -6,6 +6,7 @@ import x5 from "./lesson-5.json";
import x7 from "./lesson-7.json";
import x8 from "./lesson-8.json";
import x9 from "./lesson-9.json";
import x10 from "./lesson-10.json";
import x23 from "./lesson-23.json";
const quiz = { 0 : x1[0], 1 : x2[0], 2 : x3[0], 3 : x4[0], 4 : x5[0], 5 : x7[0], 6 : x8[0], 7 : x9[0], 8 : x23[0] };
const quiz = { 0 : x1[0], 1 : x2[0], 2 : x3[0], 3 : x4[0], 4 : x5[0], 5 : x7[0], 6 : x8[0], 7 : x9[0], 8 : x10[0], 9 : x23[0] };
export default quiz;

View File

@ -0,0 +1,119 @@
[
{
"title": "AI for Beginners: Quizzes",
"complete": "Congratulations, you completed the quiz!",
"error": "Sorry, try again",
"quizzes": [
{
"id": 110,
"title": "Generative Adversarial Networks: Pre Quiz",
"quiz": [
{
"questionText": "Gnerators take vectors and produces ____",
"answerOptions": [
{
"answerText": "videos",
"isCorrect": false
},
{
"answerText": "image",
"isCorrect": true
},
{
"answerText": "gif",
"isCorrect": false
}
]
},
{
"questionText": "GANs is short for?",
"answerOptions": [
{
"answerText": "General adversarial networks",
"isCorrect": false
},
{
"answerText": "Generative advisor networks",
"isCorrect": false
},
{
"answerText": "Generative adversarial networks",
"isCorrect": true
}
]
},
{
"questionText": "GAN uses ____ neural networks",
"answerOptions": [
{
"answerText": "1",
"isCorrect": false
},
{
"answerText": "2",
"isCorrect": true
},
{
"answerText": "3",
"isCorrect": false
}
]
}
]
},
{
"id": 210,
"title": "Generative Adversarial Networks: Post Quiz",
"quiz": [
{
"questionText": "We can use Batch normalization and BatchNorm1D to stabilize the training",
"answerOptions": [
{
"answerText": "true",
"isCorrect": true
},
{
"answerText": "false",
"isCorrect": false
}
]
},
{
"questionText": "Deep Convolutional GAN uses convolutional layers for ____ and ____",
"answerOptions": [
{
"answerText": "generator, discriminator",
"isCorrect": true
},
{
"answerText": "CNN, generator",
"isCorrect": false
},
{
"answerText": "training, testing",
"isCorrect": false
}
]
},
{
"questionText": "Problems of GAN training includes",
"answerOptions": [
{
"answerText": "Sensitivity to hyperparameters",
"isCorrect": false
},
{
"answerText": "Keeping balance between generator and discriminator",
"isCorrect": false
},
{
"answerText": "all of the above",
"isCorrect": true
}
]
}
]
}
]
}
]

View File

@ -211,6 +211,32 @@ Lesson 9E Autoencoders: Post Quiz
- KL loss
+ TF loss
Lesson 10B Generative Adversarial Networks: Pre Quiz
* Gnerators take vectors and produces ____
- videos
+ image
- gif
* GANs is short for?
- General adversarial networks
- Generative advisor networks
+ Generative adversarial networks
* GAN uses ____ neural networks
- 1
+ 2
- 3
Lesson 10E Generative Adversarial Networks: Post Quiz
* We can use Batch normalization and BatchNorm1D to stabilize the training
+ true
- false
* Deep Convolutional GAN uses convolutional layers for ____ and ____
+ generator, discriminator
- CNN, generator
- training, testing
* Problems of GAN training includes
- Sensitivity to hyperparameters
- Keeping balance between generator and discriminator
+ all of the above
Lesson 23B Multi-Agent Modeling: Pre Quiz
* By modeling the behavior of simple agents, we can understand more complex behaviors of a system.

File diff suppressed because one or more lines are too long

View File

@ -381,9 +381,9 @@
"source": [
"## DCGAN\n",
"\n",
"In the previous example, we have used dense networks for both generator and discriminator, but we know than CNNs provide better performance when dealing with images. **Deep Convolutional GAN** is similar to the architecture above, but it uses convolutional layers for generator and discriminator. \n",
"In the previous example, we have used dense networks for both generator and discriminator, but we know that CNNs provide better performance when dealing with images. **Deep Convolutional GAN** is similar to the architecture above, but it uses convolutional layers for generator and discriminator. \n",
"\n",
"The main difficulty here is to build an architecture for denerator, because it has to do an inverse task comaring to traditional CNN - it has to generate image from feature vector. In a way, this is similar to decoder part of autoencoders.That's why we will be using `Conv2DTranspose` layers in the generator."
"The main difficulty here is to build an architecture for denerator, because it has to do an inverse task compared to traditional CNN - it has to generate image from feature vector. In a way, this is similar to decoder part of autoencoders.That's why we will be using `Conv2DTranspose` layers in the generator."
]
},
{

View File

@ -2,6 +2,8 @@
In the previous section, we have learnt about **generative models** - i.e. models that can generate new images similar to the ones in the training dataset. VAE was a good example of generative model.
## [Pre-lecture quiz](https://black-ground-0cc93280f.1.azurestaticapps.net/quiz/110)
However, if we try to generate something really meaningful, like a painting at reasonable resolution, with VAE, we will see that training does not converge well. There is another architecture specifically targeted at generative models - **Generative Adversarial Networks**, or GANs.
The main idea of GAN is to have two neural networks that will be trained against each other:
@ -19,7 +21,7 @@ The architecture of discriminator does not differ from an ordinary image classif
> GAN based on convolutional networks is called [DCGAN](https://arxiv.org/pdf/1511.06434.pdf)
CNN discriminator consists of the following layers: several convolutions+poolings (with decreasing spatial size and ), one-or-more fully-connected layers to get "feature vector", final binary classifier.
CNN discriminator consists of the following layers: several convolutions+poolings (with decreasing spatial size) and, one-or-more fully-connected layers to get "feature vector", final binary classifier.
### Generator
@ -43,16 +45,22 @@ The training happens in two stages:
During this process, both generator and discriminator losses are not going down significantly. In the ideal situation, they should oscillate, corresponding to both networks improving their performance.
## Go to Notebook
* [GAN Notebook in TensorFlow/Keras](GANTF.ipynb)
* [GAN Notebook in PyTorch](GANPyTorch.ipynb)
### Problems with GAN training
GANs are known to be especially difficult to train. Here are a few problems:
* **Mode Collapse**. By this term we mean that generator learns to produce one successful image that tricks the generator, and not a variety of different images.
* **Sensitivity to hyperparameters**. Often you can see that GAN does not converge at all, and then suddenly decrease in the learning rate can lead to convergence.
* **Sensitivity to hyperparameters**. Often you can see that GAN does not converge at all, and then suddenly decrease in the learning rate can lead to convergence.
* Keeping **balance** between generator and discriminator. In many cases discriminator loss can drop to zero relatively quickly, which results in generator being unable to train further. To overcome this, we can try setting different learning rates for generator and discriminator, or skip discriminator training if the loss is already too low.
* Training for **high resolution**. It is the same problems as with autoencoders, because reconstructing too many layers of convolutional network leads to artifacts. This problem is typically solved with so-called **progressive growing**, when first a few layers are trained on low-res images, and then layers are "unblocked" or added. Another solutions would be adding extra connections between layers and training several resolutions at once - see [Multi-Scale Gradient GANs paper](https://arxiv.org/abs/1903.06048) for details.
* Training for **high resolution**. It is the same problems as with autoencoders, because reconstructing too many layers of convolutional network leads to artifacts. This problem is typically solved with so-called **progressive growing**, when first a few layers are trained on low-res images, and then layers are "unblocked" or added. Another solutions would be adding extra connections between layers and training several resolutions at once - see [Multi-Scale Gradient GANs paper](https://arxiv.org/abs/1903.06048) for details.
## [Post-lecture quiz](https://black-ground-0cc93280f.1.azurestaticapps.net/quiz/210)
> ✅ Todo: Assignment, conclusion
## References