quizzes and edits to ch 7
This commit is contained in:
parent
e2fd6a203b
commit
f2595c4378
|
|
@ -3,5 +3,7 @@ import x2 from "./lesson-2.json";
|
|||
import x3 from "./lesson-3.json";
|
||||
import x4 from "./lesson-4.json";
|
||||
import x5 from "./lesson-5.json";
|
||||
const quiz = { 0 : x1[0], 1 : x2[0], 2 : x3[0], 3 : x4[0], 4 : x5[0] };
|
||||
import x7 from "./lesson-7.json";
|
||||
import x8 from "./lesson-8.json";
|
||||
const quiz = { 0 : x1[0], 1 : x2[0], 2 : x3[0], 3 : x4[0], 4 : x5[0], 5 : x7[0], 6 : x8[0] };
|
||||
export default quiz;
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
"quizzes": [
|
||||
{
|
||||
"id": 101,
|
||||
"title": "Introduction to AI - Pre Quiz",
|
||||
"title": "Introduction to AI: Pre Quiz",
|
||||
"quiz": [
|
||||
{
|
||||
"questionText": "A famous 19th century proto-computer engineer was",
|
||||
|
|
@ -59,7 +59,7 @@
|
|||
},
|
||||
{
|
||||
"id": 201,
|
||||
"title": "Introduction to AI - Post-Quiz",
|
||||
"title": "Introduction to AI: Post-Quiz",
|
||||
"quiz": [
|
||||
{
|
||||
"questionText": "A top-down approach to AI is a model of reasoning called",
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
"quizzes": [
|
||||
{
|
||||
"id": 104,
|
||||
"title": "Neural Networks - Pre Quiz",
|
||||
"title": "Neural Networks: Pre Quiz",
|
||||
"quiz": [
|
||||
{
|
||||
"questionText": "The quality of prediction is measured by Loss function",
|
||||
|
|
@ -59,7 +59,7 @@
|
|||
},
|
||||
{
|
||||
"id": 204,
|
||||
"title": "Neural Networks - Post Quiz",
|
||||
"title": "Neural Networks: Post Quiz",
|
||||
"quiz": [
|
||||
{
|
||||
"questionText": "We use ____ for regression loss functions",
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
"quizzes": [
|
||||
{
|
||||
"id": 105,
|
||||
"title": "Frameworks - Pre Quiz",
|
||||
"title": "Frameworks: Pre Quiz",
|
||||
"quiz": [
|
||||
{
|
||||
"questionText": "Deep Neural Network training requires a lot of computations",
|
||||
|
|
@ -59,7 +59,7 @@
|
|||
},
|
||||
{
|
||||
"id": 205,
|
||||
"title": "Frameworks - Post Quiz",
|
||||
"title": "Frameworks: Post Quiz",
|
||||
"quiz": [
|
||||
{
|
||||
"questionText": "After compiling our model object, we train by calling ____ function",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,111 @@
|
|||
[
|
||||
{
|
||||
"title": "AI for Beginners: Quizzes",
|
||||
"complete": "Congratulations, you completed the quiz!",
|
||||
"error": "Sorry, try again",
|
||||
"quizzes": [
|
||||
{
|
||||
"id": 107,
|
||||
"title": "Convolutional Neural Networks: Pre Quiz",
|
||||
"quiz": [
|
||||
{
|
||||
"questionText": "To extract patterns from images we use?",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "convolutional filters",
|
||||
"isCorrect": true
|
||||
},
|
||||
{
|
||||
"answerText": "extractor",
|
||||
"isCorrect": false
|
||||
},
|
||||
{
|
||||
"answerText": "filters",
|
||||
"isCorrect": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "One of these is not a CNN Architecture",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "ResNet",
|
||||
"isCorrect": false
|
||||
},
|
||||
{
|
||||
"answerText": "MobileNet",
|
||||
"isCorrect": false
|
||||
},
|
||||
{
|
||||
"answerText": "Tensorflow",
|
||||
"isCorrect": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "CNN are mostly used for computer vision tasks.",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "true",
|
||||
"isCorrect": true
|
||||
},
|
||||
{
|
||||
"answerText": "false",
|
||||
"isCorrect": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 207,
|
||||
"title": "Convolutional Neural Networks: Post Quiz",
|
||||
"quiz": [
|
||||
{
|
||||
"questionText": "Which pooling layer is used \"scale down\" the size of the image",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "average pooling",
|
||||
"isCorrect": false
|
||||
},
|
||||
{
|
||||
"answerText": "max pooling",
|
||||
"isCorrect": false
|
||||
},
|
||||
{
|
||||
"answerText": "a and b",
|
||||
"isCorrect": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "Convolutional networks generalizes much better",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "True",
|
||||
"isCorrect": true
|
||||
},
|
||||
{
|
||||
"answerText": "False",
|
||||
"isCorrect": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "To train our neural network, we need to convert images to tensors",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "true",
|
||||
"isCorrect": true
|
||||
},
|
||||
{
|
||||
"answerText": "false",
|
||||
"isCorrect": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
[
|
||||
{
|
||||
"title": "AI for Beginners: Quizzes",
|
||||
"complete": "Congratulations, you completed the quiz!",
|
||||
"error": "Sorry, try again",
|
||||
"quizzes": [
|
||||
{
|
||||
"id": 108,
|
||||
"title": "Pre-trained Networks and Transfer Learning: Pre Quiz",
|
||||
"quiz": [
|
||||
{
|
||||
"questionText": "Transfer learning approach uses untrained models for classification",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "true",
|
||||
"isCorrect": false
|
||||
},
|
||||
{
|
||||
"answerText": "false",
|
||||
"isCorrect": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "One of these is not a normalization technique?",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "height normalization",
|
||||
"isCorrect": true
|
||||
},
|
||||
{
|
||||
"answerText": "weight normalization",
|
||||
"isCorrect": false
|
||||
},
|
||||
{
|
||||
"answerText": "layer normalization",
|
||||
"isCorrect": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "We choose Stochastic Gradient Descent(SGD) in deep learning because classical gradient descent can be ____",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "fast",
|
||||
"isCorrect": false
|
||||
},
|
||||
{
|
||||
"answerText": "slow",
|
||||
"isCorrect": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 208,
|
||||
"title": "Pre-trained Networks and Transfer Learning: Post Quiz",
|
||||
"quiz": [
|
||||
{
|
||||
"questionText": "Dropout layers act as a ____ technique",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "gradient boosting",
|
||||
"isCorrect": false
|
||||
},
|
||||
{
|
||||
"answerText": "training",
|
||||
"isCorrect": false
|
||||
},
|
||||
{
|
||||
"answerText": "regularization",
|
||||
"isCorrect": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "freezing weights of convolutional feature extractor can be done by ____",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "setting `requires_grad` property to `False`",
|
||||
"isCorrect": false
|
||||
},
|
||||
{
|
||||
"answerText": "setting `trainable` property to `False`",
|
||||
"isCorrect": false
|
||||
},
|
||||
{
|
||||
"answerText": "a and b",
|
||||
"isCorrect": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "Batch normalization is to bring values that flow through the ____ to right interval",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "algorithms",
|
||||
"isCorrect": false
|
||||
},
|
||||
{
|
||||
"answerText": "batches",
|
||||
"isCorrect": false
|
||||
},
|
||||
{
|
||||
"answerText": "neural network",
|
||||
"isCorrect": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
# Most Known CNN Architectures
|
||||
# Well-Known CNN Architectures
|
||||
|
||||
### VGG-16
|
||||
|
||||
|
|
@ -6,7 +6,7 @@ VGG-16 is a network that achieved 92.7% accuracy in ImageNet top-5 classificatio
|
|||
|
||||

|
||||
|
||||
As you can see, VGG follows traditional pyramid architecture, which is a sequence of convolution-pooling layers.
|
||||
As you can see, VGG follows a traditional pyramid architecture, which is a sequence of convolution-pooling layers.
|
||||
|
||||

|
||||
|
||||
|
|
@ -22,7 +22,7 @@ ResNet is a family of models proposed by Microsoft Research in 2015. The main id
|
|||
|
||||
The reason for using identity pass-through is to have our layer predict **the difference** between the result of a previous layer and the output of the residual block - hence the name *residual*. Those blocks are much easier to train, and one can construct networks with several hundreds of those blocks (most common variants are ResNet-52, ResNet-101 and ResNet-152).
|
||||
|
||||
You can also think of this network as being able to adjust its complexity to the dataset. Initially, when you are starting to train the network, weights values are small, and most of the signal goes through passthrough identity layers. As training progresses and weights become larger, the significance of network parameters grow, and the networks adjusts to accommodate required expressive power to correctly classify training images.
|
||||
You can also think of this network as being able to adjust its complexity to the dataset. Initially, when you are starting to train the network, the weights values are small, and most of the signal goes through passthrough identity layers. As training progresses and weights become larger, the significance of network parameters grow, and the networks adjusts to accommodate required expressive power to correctly classify training images.
|
||||
|
||||
### Google Inception
|
||||
|
||||
|
|
@ -32,9 +32,9 @@ Google Inception architecture takes this idea one step further, and builds each
|
|||
|
||||
> Image from [Researchgate](https://www.researchgate.net/figure/Inception-module-with-dimension-reductions-left-and-schema-for-Inception-ResNet-v1_fig2_355547454)
|
||||
|
||||
Here, we need to emphasize the role of 1x1 convolutions, because at first they do not make sense. Why would we need to run through the image with 1x1 filter? However, you need to remember that convolution filter also works with several depth channels (originally - RGB colors, in subsequent layers - channels for different filters), and 1x1 convolution is used to mix those input channels together using different trainable weights. It can be also viewed as downsampling (pooling) over channel dimension.
|
||||
Here, we need to emphasize the role of 1x1 convolutions, because at first they do not make sense. Why would we need to run through the image with 1x1 filter? However, you need to remember that convolution filters also work with several depth channels (originally - RGB colors, in subsequent layers - channels for different filters), and 1x1 convolution is used to mix those input channels together using different trainable weights. It can be also viewed as downsampling (pooling) over channel dimension.
|
||||
|
||||
Here is [a good blog post](https://medium.com/analytics-vidhya/talented-mr-1x1-comprehensive-look-at-1x1-convolution-in-deep-learning-f6b355825578) on the subject, and [original paper](https://arxiv.org/pdf/1312.4400.pdf).
|
||||
Here is [a good blog post](https://medium.com/analytics-vidhya/talented-mr-1x1-comprehensive-look-at-1x1-convolution-in-deep-learning-f6b355825578) on the subject, and [the original paper](https://arxiv.org/pdf/1312.4400.pdf).
|
||||
|
||||
### MobileNet
|
||||
|
||||
|
|
@ -42,4 +42,20 @@ MobileNet is a family of models with reduced size, suitable for mobile devices.
|
|||
|
||||
Here is [a good blog post on MobileNet](https://medium.com/analytics-vidhya/image-classification-with-mobilenet-cc6fbb2cd470).
|
||||
|
||||
## Conclusion
|
||||
|
||||
In this unit, you have learned the main concept behind computer vision neural networks - convolutional networks. Real-life architectures that power image classification, object detection, and even image generation networks are all based on CNNs, just with more layers and some additional training tricks.
|
||||
|
||||
## 🚀 Challenge
|
||||
|
||||
In the accompanying notebooks, there are notes at the bottom about how to obtain greater accuracy. Do some experiments to see if you can achieve higher accuracy.
|
||||
|
||||
## [Post-lecture quiz](https://black-ground-0cc93280f.1.azurestaticapps.net/quiz/207)
|
||||
|
||||
## Review & Self Study
|
||||
|
||||
While CNNs are most often used for Computer Vision tasks, they are generally good for extracting fixed-sized patterns. For example, if we are dealing with sounds, we may also want to use CNNs to look for some specific patterns in audio signal - in which case filters would be 1-dimensional (and this CNN would be called 1D-CNN). Also, sometimes 3D-CNN is used to extract features in multi-dimensional space, such as certain events occurring on video - CNN can capture certain patterns of feature changing over time. Do some review and self-study about other tasks that can be done with CNNs.
|
||||
|
||||
## [Assignment](lab/README.md)
|
||||
|
||||
In this lab, you are tasked with classifying different cat and dog breeds. These images are more complex than the MNIST dataset and of higher dimensions, and there are more than 10 classes.
|
||||
|
|
@ -1,21 +1,24 @@
|
|||
# Convolutional Neural Networks
|
||||
|
||||
We have seen before that neural networks are quite good at dealing with images, and even one-layer perceptron is able to recognize handwritten digits from MNIST dataset with reasonable accuracy. However, MNIST dataset is very special, and all digits are centered inside the image, which makes the task simpler.
|
||||
We have seen before that neural networks are quite good at dealing with images, and even one-layer perceptron is able to recognize handwritten digits from MNIST dataset with reasonable accuracy. However, the MNIST dataset is very special, and all digits are centered inside the image, which makes the task simpler.
|
||||
|
||||
## [Pre-lecture quiz](https://black-ground-0cc93280f.1.azurestaticapps.net/quiz/107)
|
||||
|
||||
In real life, we want to be able to recognize objects on the picture regardless of their exact location in the image. Computer vision is different from generic classification, because when we are trying to find a certain object in the picture, we are scanning the image looking for some specific **patterns** and their combinations. For example, when looking for a cat, we first may look for horizontal lines, which can form whiskers, and then certain combination of whiskers can tell us that it is actually a picture of a cat. Relative position and presence of certain patterns is important, and not their exact position on the image.
|
||||
In real life, we want to be able to recognize objects on a picture regardless of their exact location in the image. Computer vision is different from generic classification, because when we are trying to find a certain object in the picture, we are scanning the image looking for some specific **patterns** and their combinations. For example, when looking for a cat, we first may look for horizontal lines, which can form whiskers, and then certain a combination of whiskers can tell us that it is actually a picture of a cat. Relative position and presence of certain patterns is important, and not their exact position on the image.
|
||||
|
||||
To extract patterns, we will use the notion of **convolutional filters**. As you know, an image is represented by a 2D-matrix, or 3D-tensor with color depth. Applying a filter means that we take relatively small **filter kernel** matrix, and for each pixel in the original image we compute the weighted average with neighboring points. We can view this like a small window sliding over the whole image, and averaging out all pixels according to the weights in the filter kernel matrix.
|
||||
To extract patterns, we will use the notion of **convolutional filters**. As you know, an image is represented by a 2D-matrix, or a 3D-tensor with color depth. Applying a filter means that we take relatively small **filter kernel** matrix, and for each pixel in the original image we compute the weighted average with neighboring points. We can view this like a small window sliding over the whole image, and averaging out all pixels according to the weights in the filter kernel matrix.
|
||||
|
||||
 | 
|
||||
----|----
|
||||
|
||||
> TODO image attribution
|
||||
|
||||
For example, if we apply 3x3 vertical edge and horizontal edge filters to the MNIST digits, we can get highlights (e.g. high values) where there are vertical and horizontal edges in our original image. Thus those two filters can be used to "look for" edges. Similarly, we can design different filters to look for other low-level patterns:
|
||||
|
||||
<img src="images/lmfilters.jpg" width="500" align="center"/>
|
||||
|
||||
> Image of Leung-Malik Filter Bank, from [here](https://www.robots.ox.ac.uk/~vgg/research/texclass/filters.html)
|
||||
|
||||
> Image by the [Leung-Malik Filter Bank](https://www.robots.ox.ac.uk/~vgg/research/texclass/filters.html)
|
||||
|
||||
However, while we can design the filters to extract some patterns manually, we can also design the network in such a way that it will learn the patterns automatically. It is one of the main ideas behind the CNN.
|
||||
|
||||
|
|
@ -29,20 +32,20 @@ The way CNNs work is based on the following important ideas:
|
|||
|
||||

|
||||
|
||||
> Image from [this paper](https://www.semanticscholar.org/paper/Computer-vision-based-pedestrian-trajectory-Hislop-Lynch/26e6f74853fc9bbb7487b06dc2cf095d36c9021d), based on [this research](https://dl.acm.org/doi/abs/10.1145/1553374.1553453)
|
||||
> Image from [a paper by Hislop-Lynch](https://www.semanticscholar.org/paper/Computer-vision-based-pedestrian-trajectory-Hislop-Lynch/26e6f74853fc9bbb7487b06dc2cf095d36c9021d), based on [their research](https://dl.acm.org/doi/abs/10.1145/1553374.1553453)
|
||||
|
||||
## Continue in Notebook
|
||||
|
||||
Let's continue exploring how convolutional neural networks work, and how we can achieve trainable filters, in corresponding notebooks:
|
||||
Let's continue exploring how convolutional neural networks work, and how we can achieve trainable filters, by working through the corresponding notebooks:
|
||||
|
||||
* [Convolutional Neural Networks - PyTorch](ConvNetsPyTorch.ipynb)
|
||||
* [Convolutional Neural Networks - TensorFlow](ConvNetsTF.ipynb)
|
||||
|
||||
## Pyramid Architecture
|
||||
|
||||
Most of CNNs used for image processing follow so-called pyramid architecture. First convolutional layer applied to the original images typically has relatively low number of filters (8-16), which correspond to different pixel combinations, such as horizontal/vertical lines of strokes. At the next level, we reduce the spatial dimension of the network, and increase the number of filters, which corresponds to more possible combinations of simple features. With each layer, as we move towards the final classifier, spatial dimensions of the image decrease, and the number of filters grow.
|
||||
Most of the CNNs used for image processing follow a so-called pyramid architecture. The first convolutional layer applied to the original images typically has a relatively low number of filters (8-16), which correspond to different pixel combinations, such as horizontal/vertical lines of strokes. At the next level, we reduce the spatial dimension of the network, and increase the number of filters, which corresponds to more possible combinations of simple features. With each layer, as we move towards the final classifier, spatial dimensions of the image decrease, and the number of filters grow.
|
||||
|
||||
As an example, let's look at the architecture of VGG-16, a network that achieved 92.7% accuracy in ImageNet top-5 classification in 2014:
|
||||
As an example, let's look at the architecture of VGG-16, a network that achieved 92.7% accuracy in ImageNet's top-5 classification in 2014:
|
||||
|
||||

|
||||
|
||||
|
|
@ -50,12 +53,6 @@ As an example, let's look at the architecture of VGG-16, a network that achieved
|
|||
|
||||
> Image from [Researchgate](https://www.researchgate.net/figure/Vgg16-model-structure-To-get-the-VGG-NIN-model-we-replace-the-2-nd-4-th-6-th-7-th_fig2_335194493)
|
||||
|
||||
[**Often Used CNN Architectures**](CNN_Architectures.md)
|
||||
## Best-Known CNN Architectures
|
||||
|
||||
## [Lab](lab/README.md)
|
||||
|
||||
In the lab, you are tasked with classification of different cats and dogs breeds. Images are more complex than MNIST dataset and of higher dimensions, and there are more than 10 classes.
|
||||
|
||||
## CNNs for Other Tasks
|
||||
|
||||
While CNNs are most often used for Computer Vision tasks, they are generally good for extracting fix-sized patterns. For example, if we are dealing with sounds, we may also want to use CNNs to look for some specific patterns in audio signal - in which case filters would be 1-dimensional (and this CNN would be called 1D-CNN). Also, sometimes 3D-CNN is used to extract features in multi-dimensional space, such as certain events occurring on video - CNN can capture certain patterns of feature changing over time.
|
||||
[Continue your study about the best-known CNN architectures](CNN_Architectures.md)
|
||||
Loading…
Reference in New Issue