Skip to content

Commit c9d624d

Browse files
committed
onboarding GANs.
1 parent 120a001 commit c9d624d

File tree

8 files changed

+496
-417
lines changed

8 files changed

+496
-417
lines changed

batch-norm/Batch_Normalization_Exercises.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@
587587
"name": "python",
588588
"nbconvert_exporter": "python",
589589
"pygments_lexer": "ipython3",
590-
"version": "3.5.3"
590+
"version": "3.6.2"
591591
}
592592
},
593593
"nbformat": 4,

batch-norm/Batch_Normalization_Lesson.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2094,7 +2094,7 @@
20942094
"name": "python",
20952095
"nbconvert_exporter": "python",
20962096
"pygments_lexer": "ipython3",
2097-
"version": "3.5.3"
2097+
"version": "3.6.2"
20982098
}
20992099
},
21002100
"nbformat": 4,

batch-norm/Batch_Normalization_Solutions.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@
882882
"name": "python",
883883
"nbconvert_exporter": "python",
884884
"pygments_lexer": "ipython3",
885-
"version": "3.5.3"
885+
"version": "3.6.2"
886886
}
887887
},
888888
"nbformat": 4,

dcgan-svhn/DCGAN.ipynb

Lines changed: 21 additions & 26 deletions
Large diffs are not rendered by default.

dcgan-svhn/DCGAN_Exercises.ipynb

Lines changed: 124 additions & 79 deletions
Large diffs are not rendered by default.

face_generation/dlnd_face_generation.ipynb

Lines changed: 27 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"metadata": {
6-
"deletable": true,
7-
"editable": true
8-
},
5+
"metadata": {},
96
"source": [
107
"# Face Generation\n",
118
"In this project, you'll use generative adversarial networks to generate new images of faces.\n",
@@ -22,11 +19,7 @@
2219
{
2320
"cell_type": "code",
2421
"execution_count": null,
25-
"metadata": {
26-
"collapsed": false,
27-
"deletable": true,
28-
"editable": true
29-
},
22+
"metadata": {},
3023
"outputs": [],
3124
"source": [
3225
"data_dir = './data'\n",
@@ -46,10 +39,7 @@
4639
},
4740
{
4841
"cell_type": "markdown",
49-
"metadata": {
50-
"deletable": true,
51-
"editable": true
52-
},
42+
"metadata": {},
5343
"source": [
5444
"## Explore the Data\n",
5545
"### MNIST\n",
@@ -59,11 +49,7 @@
5949
{
6050
"cell_type": "code",
6151
"execution_count": null,
62-
"metadata": {
63-
"collapsed": false,
64-
"deletable": true,
65-
"editable": true
66-
},
52+
"metadata": {},
6753
"outputs": [],
6854
"source": [
6955
"show_n_images = 25\n",
@@ -82,10 +68,7 @@
8268
},
8369
{
8470
"cell_type": "markdown",
85-
"metadata": {
86-
"deletable": true,
87-
"editable": true
88-
},
71+
"metadata": {},
8972
"source": [
9073
"### CelebA\n",
9174
"The [CelebFaces Attributes Dataset (CelebA)](http://mmlab.ie.cuhk.edu.hk/projects/CelebA.html) dataset contains over 200,000 celebrity images with annotations. Since you're going to be generating faces, you won't need the annotations. You can view the first number of examples by changing `show_n_images`."
@@ -94,11 +77,7 @@
9477
{
9578
"cell_type": "code",
9679
"execution_count": null,
97-
"metadata": {
98-
"collapsed": false,
99-
"deletable": true,
100-
"editable": true
101-
},
80+
"metadata": {},
10281
"outputs": [],
10382
"source": [
10483
"show_n_images = 25\n",
@@ -112,10 +91,7 @@
11291
},
11392
{
11493
"cell_type": "markdown",
115-
"metadata": {
116-
"deletable": true,
117-
"editable": true
118-
},
94+
"metadata": {},
11995
"source": [
12096
"## Preprocess the Data\n",
12197
"Since the project's main focus is on building the GANs, we'll preprocess the data for you. The values of the MNIST and CelebA dataset will be in the range of -0.5 to 0.5 of 28x28 dimensional images. The CelebA images will be cropped to remove parts of the image that don't include a face, then resized down to 28x28.\n",
@@ -137,11 +113,7 @@
137113
{
138114
"cell_type": "code",
139115
"execution_count": null,
140-
"metadata": {
141-
"collapsed": false,
142-
"deletable": true,
143-
"editable": true
144-
},
116+
"metadata": {},
145117
"outputs": [],
146118
"source": [
147119
"\"\"\"\n",
@@ -164,10 +136,7 @@
164136
},
165137
{
166138
"cell_type": "markdown",
167-
"metadata": {
168-
"deletable": true,
169-
"editable": true
170-
},
139+
"metadata": {},
171140
"source": [
172141
"### Input\n",
173142
"Implement the `model_inputs` function to create TF Placeholders for the Neural Network. It should create the following placeholders:\n",
@@ -181,11 +150,7 @@
181150
{
182151
"cell_type": "code",
183152
"execution_count": null,
184-
"metadata": {
185-
"collapsed": false,
186-
"deletable": true,
187-
"editable": true
188-
},
153+
"metadata": {},
189154
"outputs": [],
190155
"source": [
191156
"import problem_unittests as tests\n",
@@ -212,10 +177,7 @@
212177
},
213178
{
214179
"cell_type": "markdown",
215-
"metadata": {
216-
"deletable": true,
217-
"editable": true
218-
},
180+
"metadata": {},
219181
"source": [
220182
"### Discriminator\n",
221183
"Implement `discriminator` to create a discriminator neural network that discriminates on `images`. This function should be able to reuse the variables in the neural network. Use [`tf.variable_scope`](https://www.tensorflow.org/api_docs/python/tf/variable_scope) with a scope name of \"discriminator\" to allow the variables to be reused. The function should return a tuple of (tensor output of the discriminator, tensor logits of the discriminator)."
@@ -224,11 +186,7 @@
224186
{
225187
"cell_type": "code",
226188
"execution_count": null,
227-
"metadata": {
228-
"collapsed": false,
229-
"deletable": true,
230-
"editable": true
231-
},
189+
"metadata": {},
232190
"outputs": [],
233191
"source": [
234192
"def discriminator(images, reuse=False):\n",
@@ -251,10 +209,7 @@
251209
},
252210
{
253211
"cell_type": "markdown",
254-
"metadata": {
255-
"deletable": true,
256-
"editable": true
257-
},
212+
"metadata": {},
258213
"source": [
259214
"### Generator\n",
260215
"Implement `generator` to generate an image using `z`. This function should be able to reuse the variables in the neural network. Use [`tf.variable_scope`](https://www.tensorflow.org/api_docs/python/tf/variable_scope) with a scope name of \"generator\" to allow the variables to be reused. The function should return the generated 28 x 28 x `out_channel_dim` images."
@@ -263,11 +218,7 @@
263218
{
264219
"cell_type": "code",
265220
"execution_count": null,
266-
"metadata": {
267-
"collapsed": false,
268-
"deletable": true,
269-
"editable": true
270-
},
221+
"metadata": {},
271222
"outputs": [],
272223
"source": [
273224
"def generator(z, out_channel_dim, is_train=True):\n",
@@ -291,10 +242,7 @@
291242
},
292243
{
293244
"cell_type": "markdown",
294-
"metadata": {
295-
"deletable": true,
296-
"editable": true
297-
},
245+
"metadata": {},
298246
"source": [
299247
"### Loss\n",
300248
"Implement `model_loss` to build the GANs for training and calculate the loss. The function should return a tuple of (discriminator loss, generator loss). Use the following functions you implemented:\n",
@@ -305,11 +253,7 @@
305253
{
306254
"cell_type": "code",
307255
"execution_count": null,
308-
"metadata": {
309-
"collapsed": false,
310-
"deletable": true,
311-
"editable": true
312-
},
256+
"metadata": {},
313257
"outputs": [],
314258
"source": [
315259
"def model_loss(input_real, input_z, out_channel_dim):\n",
@@ -333,10 +277,7 @@
333277
},
334278
{
335279
"cell_type": "markdown",
336-
"metadata": {
337-
"deletable": true,
338-
"editable": true
339-
},
280+
"metadata": {},
340281
"source": [
341282
"### Optimization\n",
342283
"Implement `model_opt` to create the optimization operations for the GANs. Use [`tf.trainable_variables`](https://www.tensorflow.org/api_docs/python/tf/trainable_variables) to get all the trainable variables. Filter the variables with names that are in the discriminator and generator scope names. The function should return a tuple of (discriminator training operation, generator training operation)."
@@ -345,11 +286,7 @@
345286
{
346287
"cell_type": "code",
347288
"execution_count": null,
348-
"metadata": {
349-
"collapsed": false,
350-
"deletable": true,
351-
"editable": true
352-
},
289+
"metadata": {},
353290
"outputs": [],
354291
"source": [
355292
"def model_opt(d_loss, g_loss, learning_rate, beta1):\n",
@@ -374,10 +311,7 @@
374311
},
375312
{
376313
"cell_type": "markdown",
377-
"metadata": {
378-
"deletable": true,
379-
"editable": true
380-
},
314+
"metadata": {},
381315
"source": [
382316
"## Neural Network Training\n",
383317
"### Show Output\n",
@@ -388,9 +322,7 @@
388322
"cell_type": "code",
389323
"execution_count": null,
390324
"metadata": {
391-
"collapsed": true,
392-
"deletable": true,
393-
"editable": true
325+
"collapsed": true
394326
},
395327
"outputs": [],
396328
"source": [
@@ -423,10 +355,7 @@
423355
},
424356
{
425357
"cell_type": "markdown",
426-
"metadata": {
427-
"deletable": true,
428-
"editable": true
429-
},
358+
"metadata": {},
430359
"source": [
431360
"### Train\n",
432361
"Implement `train` to build and train the GANs. Use the following functions you implemented:\n",
@@ -441,9 +370,7 @@
441370
"cell_type": "code",
442371
"execution_count": null,
443372
"metadata": {
444-
"collapsed": true,
445-
"deletable": true,
446-
"editable": true
373+
"collapsed": true
447374
},
448375
"outputs": [],
449376
"source": [
@@ -473,10 +400,7 @@
473400
},
474401
{
475402
"cell_type": "markdown",
476-
"metadata": {
477-
"deletable": true,
478-
"editable": true
479-
},
403+
"metadata": {},
480404
"source": [
481405
"### MNIST\n",
482406
"Test your GANs architecture on MNIST. After 2 epochs, the GANs should be able to generate images that look like handwritten digits. Make sure the loss of the generator is lower than the loss of the discriminator or close to 0."
@@ -486,9 +410,6 @@
486410
"cell_type": "code",
487411
"execution_count": null,
488412
"metadata": {
489-
"collapsed": false,
490-
"deletable": true,
491-
"editable": true,
492413
"scrolled": true
493414
},
494415
"outputs": [],
@@ -512,10 +433,7 @@
512433
},
513434
{
514435
"cell_type": "markdown",
515-
"metadata": {
516-
"deletable": true,
517-
"editable": true
518-
},
436+
"metadata": {},
519437
"source": [
520438
"### CelebA\n",
521439
"Run your GANs on CelebA. It will take around 20 minutes on the average GPU to run one epoch. You can run the whole epoch or stop when it starts to generate realistic faces."
@@ -525,9 +443,6 @@
525443
"cell_type": "code",
526444
"execution_count": null,
527445
"metadata": {
528-
"collapsed": false,
529-
"deletable": true,
530-
"editable": true,
531446
"scrolled": true
532447
},
533448
"outputs": [],
@@ -551,10 +466,7 @@
551466
},
552467
{
553468
"cell_type": "markdown",
554-
"metadata": {
555-
"deletable": true,
556-
"editable": true
557-
},
469+
"metadata": {},
558470
"source": [
559471
"### Submitting This Project\n",
560472
"When submitting this project, make sure to run all the cells before saving the notebook. Save the notebook file as \"dlnd_face_generation.ipynb\" and save it as a HTML file under \"File\" -> \"Download as\". Include the \"helper.py\" and \"problem_unittests.py\" files in your submission."
@@ -577,9 +489,9 @@
577489
"name": "python",
578490
"nbconvert_exporter": "python",
579491
"pygments_lexer": "ipython3",
580-
"version": "3.5.2"
492+
"version": "3.6.2"
581493
}
582494
},
583495
"nbformat": 4,
584-
"nbformat_minor": 0
496+
"nbformat_minor": 1
585497
}

0 commit comments

Comments
 (0)