Skip to content
This repository was archived by the owner on Dec 2, 2021. It is now read-only.

Commit 444d1d4

Browse files
committed
text-only update
1 parent 24dede9 commit 444d1d4

File tree

1 file changed

+32
-43
lines changed

1 file changed

+32
-43
lines changed

code/model_training.ipynb

+32-43
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"# Follow-Me Project\n",
88
"Congratulations on reaching the final project of the Robotics Nanodegree! \n",
99
"\n",
10-
"Previously you worked on the Semantic Segmentation lab where you built a deep learning network that locates a particular human target within an image. For this project, you will utilize what you implemented and learned from that lab and extend it to train a deep learning model that will allow a simulated quadcopter to follow around the person that it detects! \n",
10+
"Previously, you worked on the Semantic Segmentation lab where you built a deep learning network that locates a particular human target within an image. For this project, you will utilize what you implemented and learned from that lab and extend it to train a deep learning model that will allow a simulated quadcopter to follow around the person that it detects! \n",
1111
"\n",
12-
"Most of the code below will be familiar in comparison to the lab with some minor modifications. So you can work off of your existing solution, and modify and improve upon it to train the best possible model for this task.\n",
12+
"Most of the code below is similar to the lab with some minor modifications. You can start with your existing solution, and modify and improve upon it to train the best possible model for this task.\n",
1313
"\n",
1414
"You can click on any of the following to quickly jump to that part of this notebook:\n",
1515
"1. [Data Collection](#data)\n",
@@ -25,9 +25,8 @@
2525
"metadata": {},
2626
"source": [
2727
"## Data Collection<a id='data'></a>\n",
28-
"We have provided you with a dataset for this project. If you haven't already downloaded the training and validation datasets, you can check out the README for this project's repo for instructions as well.\n",
29-
"\n",
30-
"Alternatively, you can also collect your own data and see how well your model can perform on that or tweak your model accordingly. You can check out the \"Collecting Data\" section in the Project Lesson in the Classroom for more details!"
28+
"We have provided you with a starting dataset for this project. Download instructions can be found in the README for this project's repo.\n",
29+
"Alternatively, you can collect additional data of your own to improve your model. Check out the \"Collecting Data\" section in the Project Lesson in the Classroom for more details!"
3130
]
3231
},
3332
{
@@ -63,19 +62,15 @@
6362
"metadata": {},
6463
"source": [
6564
"## FCN Layers <a id='fcn'></a>\n",
66-
"In the Classroom, we discussed the different layers that constitute a fully convolutional network. The following code will intoduce you to the functions that you will be using to build out your model."
65+
"In the Classroom, we discussed the different layers that constitute a fully convolutional network (FCN). The following code will introduce you to the functions that you need to build your semantic segmentation model."
6766
]
6867
},
6968
{
7069
"cell_type": "markdown",
7170
"metadata": {},
7271
"source": [
7372
"### Separable Convolutions\n",
74-
"The Encoder for your FCN will essentially require separable convolution layers. Below we have implemented two functions - one which you can call upon to build out separable convolutions or regular convolutions. Each with batch normalization and with the ReLU activation function applied to the layers. \n",
75-
"\n",
76-
"While we recommend the use of separable convolutions thanks to their advantages we covered in the Classroom, some of the helper code we will present for your model will require the use for regular convolutions. But we encourage you to try and experiment with each as well!\n",
77-
"\n",
78-
"The following will help you create the encoder block and the final model for your architecture."
73+
"The Encoder for your FCN will essentially require separable convolution layers, due to their advantages as explained in the classroom. The 1x1 convolution layer in the FCN, however, is a regular convolution. Implementations for both are provided below for your use. Each includes batch normalization with the ReLU activation function applied to the layers. "
7974
]
8075
},
8176
{
@@ -106,7 +101,7 @@
106101
"metadata": {},
107102
"source": [
108103
"### Bilinear Upsampling\n",
109-
"The following helper function will help implement the bilinear upsampling layer. Currently, upsampling by a factor of 2 is recommended but you can try out different factors as well. You will use this to create the decoder block later!"
104+
"The following helper function implements the bilinear upsampling layer. Upsampling by a factor of 2 is generally recommended, but you can try out different factors as well. Upsampling is used in the decoder block of the FCN."
110105
]
111106
},
112107
{
@@ -127,21 +122,18 @@
127122
"metadata": {},
128123
"source": [
129124
"## Build the Model <a id='build'></a>\n",
130-
"In the following cells, we will cover how to build the model for the task at hand. \n",
131-
"\n",
132-
"- We will first create an Encoder Block, where you will create a separable convolution layer using an input layer and the size(depth) of the filters as your inputs.\n",
133-
"- Next, you will create the Decoder Block, where you will create an upsampling layer using bilinear upsampling, followed by a layer concatentaion, and some separable convolution layers.\n",
134-
"- Finally, you will combine the above two and create the model. In this step you will be able to experiment with different number of layers and filter sizes for each to build your model.\n",
135-
"\n",
136-
"Let's cover them individually below."
125+
"In the following cells, you will build an FCN to train a model to detect the hero target and location within an image. The steps are:\n",
126+
"- Create an `encoder_block`\n",
127+
"- Create a `decoder_block`\n",
128+
"- Build the FCN consiting of encoder block(s), a 1x1 convolution, and decoder block(s). This step requires experimentation with different numbers of layers and filter sizes to build your model."
137129
]
138130
},
139131
{
140132
"cell_type": "markdown",
141133
"metadata": {},
142134
"source": [
143135
"### Encoder Block\n",
144-
"Below you will create a separable convolution layer using the separable_conv2d_batchnorm() function. The `filters` parameter defines the size or depth of the output layer. For example, 32 or 64. "
136+
"Create an encoder block that includes a separable convolution layer using the separable_conv2d_batchnorm() function. The `filters` parameter defines the size or depth of the output layer. For example, 32 or 64. "
145137
]
146138
},
147139
{
@@ -164,8 +156,7 @@
164156
"metadata": {},
165157
"source": [
166158
"### Decoder Block\n",
167-
"The decoder block, as covered in the Classroom, comprises of three steps -\n",
168-
"\n",
159+
"The decoder block, as covered in the Classroom, comprises of three steps:\n",
169160
"- A bilinear upsampling layer using the upsample_bilinear() function. The current recommended factor for upsampling is set to 2.\n",
170161
"- A layer concatenation step. This step is similar to skip connections. You will concatenate the upsampled small_ip_layer and the large_ip_layer.\n",
171162
"- Some (one or two) additional separable convolution layers to extract some more spatial information from prior layers."
@@ -196,12 +187,12 @@
196187
"source": [
197188
"### Model\n",
198189
"\n",
199-
"Now that you have the encoder and decoder blocks ready, you can go ahead and build your model architecture! \n",
190+
"Now that you have the encoder and decoder blocks ready, go ahead and build your FCN architecture! \n",
200191
"\n",
201-
"There are three steps to the following:\n",
202-
"- Add encoder blocks to build out initial set of layers. This is similar to how you added regular convolutional layers in your CNN lab.\n",
203-
"- Add 1x1 Convolution layer using conv2d_batchnorm() function. Remember that 1x1 Convolutions require a kernel and stride of 1.\n",
204-
"- Add decoder blocks for upsampling and skip connections."
192+
"There are three steps:\n",
193+
"- Add encoder blocks to build the encoder layers. This is similar to how you added regular convolutional layers in your CNN lab.\n",
194+
"- Add a 1x1 Convolution layer using the conv2d_batchnorm() function. Remember that 1x1 Convolutions require a kernel and stride of 1.\n",
195+
"- Add decoder blocks for the decoder layers."
205196
]
206197
},
207198
{
@@ -231,9 +222,9 @@
231222
"metadata": {},
232223
"source": [
233224
"## Training <a id='training'></a>\n",
234-
"The following cells will utilize the model you created and define an ouput layer based on the input and the number of classes.Following that you will define the hyperparameters to compile and train your model!\n",
225+
"The following cells will use the FCN you created and define an ouput layer based on the size of the processed image and the number of classes recognized. You will define the hyperparameters to compile and train your model.\n",
235226
"\n",
236-
"Please Note: For the project you will be working with images of dimensions 160x160x3."
227+
"Please Note: For this project, the helper code in `data_iterator.py` will resize the copter images to 160x160x3 to speed up training."
237228
]
238229
},
239230
{
@@ -262,7 +253,7 @@
262253
"metadata": {},
263254
"source": [
264255
"### Hyperparameters\n",
265-
"Below you can define and tune your hyperparameters.\n",
256+
"Define and tune your hyperparameters.\n",
266257
"- **batch_size**: number of training samples/images that get propagated through the network in a single pass.\n",
267258
"- **num_epochs**: number of times the entire training dataset gets propagated through the network.\n",
268259
"- **steps_per_epoch**: number of batches of training images that go through the network in 1 epoch. We have provided you with a default value. One recommended value to try would be based on the total number of images in training dataset divided by the batch_size.\n",
@@ -343,12 +334,12 @@
343334
"source": [
344335
"## Prediction <a id='prediction'></a>\n",
345336
"\n",
346-
"Now that you have your model trained and saved, you can use it to make predictions on your validation datasets! These predictions will help you understand and later evaluate how well your model is doing under different conditions.\n",
337+
"Now that you have your model trained and saved, you can make predictions on your validation dataset. These predictions can be compared to the mask images, which are the ground truth labels, to evaluate how well your model is doing under different conditions.\n",
347338
"\n",
348-
"There are three different predictions that you will be calculating using the helper code provided to you:\n",
349-
"- **patrol_with_targ**: This will help test how well the network can detect the hero from a distance.\n",
350-
"- **patrol_non_targ**: This will help test how often the network makes a mistake and identifies the wrong person as the target.\n",
351-
"- **following_images**: This will help test how well the network can identify the target while following them."
339+
"There are three different predictions available from the helper code provided:\n",
340+
"- **patrol_with_targ**: Test how well the network can detect the hero from a distance.\n",
341+
"- **patrol_non_targ**: Test how often the network makes a mistake and identifies the wrong person as the target.\n",
342+
"- **following_images**: Test how well the network can identify the target while following them."
352343
]
353344
},
354345
{
@@ -368,9 +359,8 @@
368359
"cell_type": "markdown",
369360
"metadata": {},
370361
"source": [
371-
"The following will write predictions to file and return paths to the appropriate directories.\n",
372-
"\n",
373-
"The `run_num` parameter below is useful to define or group all the data for a particular model run. You can change it for different runs. For example, 'run_1', 'run_2' etc."
362+
"The following cell will write predictions to files and return paths to the appropriate directories.\n",
363+
"The `run_num` parameter is used to define or group all the data for a particular model run. You can change it for different runs. For example, 'run_1', 'run_2' etc."
374364
]
375365
},
376366
{
@@ -397,9 +387,8 @@
397387
"cell_type": "markdown",
398388
"metadata": {},
399389
"source": [
400-
"Now lets look at your predictions, and compare to the ground truth labels and actual images.\n",
401-
"\n",
402-
"Run each of the following cells to visualize some sample images from the predictions on the validation set."
390+
"Now lets look at your predictions, and compare them to the ground truth labels and original images.\n",
391+
"Run each of the following cells to visualize some sample images from the predictions in the validation set."
403392
]
404393
},
405394
{
@@ -455,7 +444,7 @@
455444
"metadata": {},
456445
"source": [
457446
"## Evaluation <a id='evaluation'></a>\n",
458-
"Let's evaluate your model! We are providing you different scores that can help you evaluate your model better for each different condition discussed during the Prediction step. "
447+
"Evaluate your model! The following cells include several different scores to help you evaluate your model under the different conditions discussed during the Prediction step. "
459448
]
460449
},
461450
{
@@ -554,7 +543,7 @@
554543
"name": "python",
555544
"nbconvert_exporter": "python",
556545
"pygments_lexer": "ipython3",
557-
"version": "3.5.2"
546+
"version": "3.4.1"
558547
},
559548
"widgets": {
560549
"state": {},

0 commit comments

Comments
 (0)