title

Convolutional Neural Networks - Deep Learning basics with Python, TensorFlow and Keras p.3

description

Welcome to a tutorial where we'll be discussing Convolutional Neural Networks (Convnets and CNNs), using one to classify dogs and cats with the dataset we built in the previous tutorial.
Text tutorials and sample code: https://pythonprogramming.net/convolutional-neural-network-deep-learning-python-tensorflow-keras/
Discord: https://discord.gg/sentdex
Support the content: https://pythonprogramming.net/support-donate/
Twitter: https://twitter.com/sentdex
Facebook: https://www.facebook.com/pythonprogramming.net/
Twitch: https://www.twitch.tv/sentdex
G+: https://plus.google.com/+sentdex

detail

{'title': 'Convolutional Neural Networks - Deep Learning basics with Python, TensorFlow and Keras p.3', 'heatmap': [{'end': 563.049, 'start': 512.511, 'weight': 0.831}, {'end': 965.754, 'start': 947.6, 'weight': 0.719}], 'summary': 'Covers the application of convolutional neural networks to classify dogs versus cats using a dataset built in the previous video, explaining the steps involved in convolution and pooling, and achieving a validation accuracy of 73% after one epoch, with potential to breach 80% after 10 epochs using tensorflow.', 'chapters': [{'end': 145.074, 'segs': [{'end': 48.416, 'src': 'embed', 'start': 1.755, 'weight': 0, 'content': [{'end': 8.76, 'text': "What's going on everybody and welcome to part three of our deep learning with Python, TensorFlow, and Keras tutorial series.", 'start': 1.755, 'duration': 7.005}, {'end': 9.52, 'text': 'In this video,', 'start': 9.06, 'duration': 0.46}, {'end': 18.826, 'text': "what we're going to be covering is convolutional neural networks and applying the data set that we worked on building in the last video to a convolutional neural network,", 'start': 9.52, 'duration': 9.306}, {'end': 23.569, 'text': 'in hopes that we can get this neural network to classify dogs versus cats.', 'start': 18.826, 'duration': 4.743}, {'end': 29.511, 'text': 'Now first, What we should do is cover quickly how convolutional neural networks work,', 'start': 23.669, 'duration': 5.842}, {'end': 36.353, 'text': 'just to get some of an intuition of why we use ConvNets with imagery types of data.', 'start': 29.511, 'duration': 6.842}, {'end': 39.834, 'text': 'So let me just pull this over from the text-based version.', 'start': 36.433, 'duration': 3.401}, {'end': 42.415, 'text': "I didn't really want to have to redraw everything again.", 'start': 39.854, 'duration': 2.561}, {'end': 48.416, 'text': "So in general, you're going to have the following steps are going to be taken.", 'start': 42.535, 'duration': 5.881}], 'summary': 'Part three covers convolutional neural networks and classifying dogs vs. cats.', 'duration': 46.661, 'max_score': 1.755, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/WvoLTXIjBYU/pics/WvoLTXIjBYU1755.jpg'}, {'end': 112.235, 'src': 'embed', 'start': 86.412, 'weight': 2, 'content': [{'end': 94.337, 'text': "you know, there's already been a few convolution layers, but anyways, the idea is, then you have a window like a convolutional window.", 'start': 86.412, 'duration': 7.925}, {'end': 104.951, 'text': "in this case it's a 3x3 window, And in that window the convolution is going to attempt to simplify what it finds down to some sort of value.", 'start': 94.337, 'duration': 10.614}, {'end': 112.235, 'text': 'Now, when it does that, the window is going to shift over and do the exact same thing just a bunch of times.', 'start': 106.432, 'duration': 5.803}], 'summary': 'The convolutional layer uses a 3x3 window to simplify data and repeats the process multiple times.', 'duration': 25.823, 'max_score': 86.412, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/WvoLTXIjBYU/pics/WvoLTXIjBYU86412.jpg'}], 'start': 1.755, 'title': 'Convolutional neural networks', 'summary': 'Covers the application of convolutional neural networks to classify dogs versus cats using a data set built in the previous video, explaining the steps involved in convolution and pooling, and providing insights into the use of convnets with imagery types of data.', 'chapters': [{'end': 145.074, 'start': 1.755, 'title': 'Convolutional neural networks', 'summary': 'Covers the application of convolutional neural networks to classify dogs versus cats using a data set built in the previous video, explaining the steps involved in convolution and pooling, and providing insights into the use of convnets with imagery types of data.', 'duration': 143.319, 'highlights': ['Explanation of the steps involved in convolution and pooling, including the use of a 3x3 window for convolution and the concept of shifting the window over to simplify values, with a focus on the application of ConvNets to classify dogs versus cats.', 'Emphasizing the utility of ConvNets with imagery types of data and the process of converting images to pixel data, with a mention of the practical application of convolutional neural networks in classifying dogs versus cats using a built data set.', 'Reference to the practical machine learning tutorial series for a deeper explanation of deep learning, and the use of Keras for specifying the window size in the convolution process, with a note on exploring deeper details of deep learning in the series.', 'Introduction to the tutorial series on deep learning with Python, TensorFlow, and Keras, focusing on the application of convolutional neural networks to classify dogs versus cats using a previously built data set.']}], 'duration': 143.319, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/WvoLTXIjBYU/pics/WvoLTXIjBYU1755.jpg', 'highlights': ['Introduction to the tutorial series on deep learning with Python, TensorFlow, and Keras, focusing on the application of convolutional neural networks to classify dogs versus cats using a previously built data set.', 'Emphasizing the utility of ConvNets with imagery types of data and the process of converting images to pixel data, with a mention of the practical application of convolutional neural networks in classifying dogs versus cats using a built data set.', 'Explanation of the steps involved in convolution and pooling, including the use of a 3x3 window for convolution and the concept of shifting the window over to simplify values, with a focus on the application of ConvNets to classify dogs versus cats.', 'Reference to the practical machine learning tutorial series for a deeper explanation of deep learning, and the use of Keras for specifying the window size in the convolution process, with a note on exploring deeper details of deep learning in the series.']}, {'end': 1117.734, 'segs': [{'end': 209.067, 'src': 'embed', 'start': 180.17, 'weight': 1, 'content': [{'end': 184.752, 'text': "Then let's say you've got a bunch of convolutions, right? This is just a bunch.", 'start': 180.17, 'duration': 4.582}, {'end': 190.556, 'text': "The next thing that's going to likely happen, you don't have to, but this is pretty common, is to do a pooling layer.", 'start': 185.213, 'duration': 5.343}, {'end': 194.598, 'text': 'So in general, the most common form of pooling is max pooling.', 'start': 191.056, 'duration': 3.542}, {'end': 198.62, 'text': "So again, let's say you do a max pooling of a 3x3 window.", 'start': 195.058, 'duration': 3.562}, {'end': 201.862, 'text': 'Well, all max pooling does is find the max value.', 'start': 199.041, 'duration': 2.821}, {'end': 204.784, 'text': "So in this window, the maximum value, it's a 4.", 'start': 202.002, 'duration': 2.782}, {'end': 209.067, 'text': 'Then it shifts it over and again and again, so you can see how it worked basically down here.', 'start': 204.784, 'duration': 4.283}], 'summary': 'Convolutional neural networks use max pooling to find maximum values in a 3x3 window.', 'duration': 28.897, 'max_score': 180.17, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/WvoLTXIjBYU/pics/WvoLTXIjBYU180170.jpg'}, {'end': 249.649, 'src': 'embed', 'start': 223.797, 'weight': 0, 'content': [{'end': 233.881, 'text': 'So the more initial layers in a convolutional neural network are going to be finding things like edges and lines.', 'start': 223.797, 'duration': 10.084}, {'end': 239.763, 'text': "And then as you go, you're going to find maybe squiggles.", 'start': 233.961, 'duration': 5.802}, {'end': 242.144, 'text': "And then maybe you'll find circles.", 'start': 239.963, 'duration': 2.181}, {'end': 244.125, 'text': "And then maybe you'll find squares.", 'start': 242.284, 'duration': 1.841}, {'end': 249.649, 'text': "And then soon you're going to find, I don't know, like very small like features.", 'start': 245.505, 'duration': 4.144}], 'summary': 'Cnns identify edges, lines, circles, and squares in initial layers, then progress to smaller features.', 'duration': 25.852, 'max_score': 223.797, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/WvoLTXIjBYU/pics/WvoLTXIjBYU223797.jpg'}, {'end': 343.225, 'src': 'embed', 'start': 314.381, 'weight': 3, 'content': [{'end': 317.183, 'text': 'Anyways, this was Inception off of the ImageNet dataset.', 'start': 314.381, 'duration': 2.802}, {'end': 319.906, 'text': 'But anyway, you can check out A Deep Dream of a Neural Network if you want.', 'start': 317.203, 'duration': 2.703}, {'end': 328.293, 'text': 'Also, you can check out that series, the Unconventional Neural Network series, for more interesting projects like that.', 'start': 320.306, 'duration': 7.987}, {'end': 330.054, 'text': 'So okay.', 'start': 328.333, 'duration': 1.721}, {'end': 339.702, 'text': 'so the first thing that we want to do is bring in tensorflow and all the things that we need to make a convolutional neural network.', 'start': 330.054, 'duration': 9.648}, {'end': 343.225, 'text': "so we're going to in not do that.", 'start': 339.702, 'duration': 3.523}], 'summary': 'Inception model trained on imagenet dataset using tensorflow for neural network projects.', 'duration': 28.844, 'max_score': 314.381, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/WvoLTXIjBYU/pics/WvoLTXIjBYU314381.jpg'}, {'end': 469.74, 'src': 'embed', 'start': 436.741, 'weight': 5, 'content': [{'end': 442.226, 'text': "And then we'll do the same thing for y.", 'start': 436.741, 'duration': 5.485}, {'end': 447.35, 'text': 'So x and y.', 'start': 442.226, 'duration': 5.124}, {'end': 454.616, 'text': 'So then the first thing we want to do before we feed data through a neural network is consider normalizing that data.', 'start': 447.35, 'duration': 7.266}, {'end': 459.76, 'text': 'The easiest way to normalize data is going to be to scale that data.', 'start': 455.677, 'duration': 4.083}, {'end': 463.911, 'text': "In our case, we're using imagery data.", 'start': 460.626, 'duration': 3.285}, {'end': 469.74, 'text': 'So actually the easiest way to scale the imagery data is we know what the maximum value and the min value is.', 'start': 464.031, 'duration': 5.709}], 'summary': 'Normalize imagery data by scaling to min and max values.', 'duration': 32.999, 'max_score': 436.741, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/WvoLTXIjBYU/pics/WvoLTXIjBYU436741.jpg'}, {'end': 563.049, 'src': 'heatmap', 'start': 504.664, 'weight': 6, 'content': [{'end': 511.771, 'text': "So we'll start with, not a capital M, model equals sequential, because it's just going to be a simple sequential model.", 'start': 504.664, 'duration': 7.107}, {'end': 516.535, 'text': "And then we're going to start using that model.add syntax that we've been using.", 'start': 512.511, 'duration': 4.024}, {'end': 518.198, 'text': "So we're going to say conv2d.", 'start': 516.635, 'duration': 1.563}, {'end': 525.452, 'text': "we're going to start with that convolutional layer, and this can be um, we can, probably.", 'start': 519.844, 'duration': 5.608}, {'end': 528.075, 'text': "we're probably going to get away with almost anything we pass here.", 'start': 525.452, 'duration': 2.623}, {'end': 533.643, 'text': "i'm going to pass 64, though, and then we're going to pass the window that we want to use.", 'start': 528.075, 'duration': 5.568}, {'end': 535.526, 'text': 'uh, three by three.', 'start': 533.643, 'duration': 1.883}, {'end': 545.997, 'text': 'and then, finally, the input underscore shape is going to be equal to the x dot shape, and then here you can just say one colon.', 'start': 536.707, 'duration': 9.29}, {'end': 547.919, 'text': "so we're going to skip that first, like negative one.", 'start': 545.997, 'duration': 1.922}, {'end': 553.045, 'text': 'so each, because negative one again is was how many of those feature sets did we have right?', 'start': 547.919, 'duration': 5.126}, {'end': 556.586, 'text': "So we don't need that, because that's not actually the input shape.", 'start': 553.445, 'duration': 3.141}, {'end': 558.987, 'text': "It's going to be the shape of the data we're actually throwing in.", 'start': 556.686, 'duration': 2.301}, {'end': 562.569, 'text': "So it's not negative 1, but it is 50 by 50 by 1.", 'start': 559.028, 'duration': 3.541}, {'end': 563.049, 'text': "That's true.", 'start': 562.569, 'duration': 0.48}], 'summary': 'Creating a sequential model with a convolutional layer of 64 filters using a 3x3 window and an input shape of 50x50x1.', 'duration': 23.411, 'max_score': 504.664, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/WvoLTXIjBYU/pics/WvoLTXIjBYU504664.jpg'}, {'end': 874.948, 'src': 'embed', 'start': 850.33, 'weight': 7, 'content': [{'end': 855.915, 'text': 'Usually I find negative results start coming in if I start trying to do like a batch size of like thousands.', 'start': 850.33, 'duration': 5.585}, {'end': 858.177, 'text': 'But it depends on the size of your data.', 'start': 856.495, 'duration': 1.682}, {'end': 862.141, 'text': "So it's really going to kind of scale with how big your data is.", 'start': 858.657, 'duration': 3.484}, {'end': 867.505, 'text': "If you've got like a data set of a billion samples, you could probably get away with a batch size of a few thousand.", 'start': 862.201, 'duration': 5.304}, {'end': 869.786, 'text': 'but anyways, um yeah.', 'start': 868.306, 'duration': 1.48}, {'end': 871.107, 'text': 'so, model.fit batch size.', 'start': 869.786, 'duration': 1.321}, {'end': 874.948, 'text': "we'll talk more on that in a little, uh, in the next tutorial.", 'start': 871.107, 'duration': 3.841}], 'summary': 'Larger data sets may allow batch sizes of a few thousand, impacting model performance.', 'duration': 24.618, 'max_score': 850.33, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/WvoLTXIjBYU/pics/WvoLTXIjBYU850330.jpg'}, {'end': 993.124, 'src': 'heatmap', 'start': 947.6, 'weight': 8, 'content': [{'end': 951.781, 'text': 'Oh, and we did it because we copy and pasted.', 'start': 947.6, 'duration': 4.181}, {'end': 952.381, 'text': 'Got it.', 'start': 952.001, 'duration': 0.38}, {'end': 954.041, 'text': 'Chickity check.', 'start': 953.081, 'duration': 0.96}, {'end': 958.042, 'text': 'Please no more errors.', 'start': 957.062, 'duration': 0.98}, {'end': 958.702, 'text': "That'd be really nice.", 'start': 958.062, 'duration': 0.64}, {'end': 962.052, 'text': "All right, so I think we're training finally.", 'start': 960.211, 'duration': 1.841}, {'end': 965.754, 'text': "Yes, all right, so we're already at 64, 65.", 'start': 962.272, 'duration': 3.482}, {'end': 966.415, 'text': "We're doing pretty good.", 'start': 965.754, 'duration': 0.661}, {'end': 970.197, 'text': "I don't know if we set, oh, we didn't specify epochs.", 'start': 968.016, 'duration': 2.181}, {'end': 972.299, 'text': "So let's go ahead and specify.", 'start': 970.457, 'duration': 1.842}, {'end': 977.542, 'text': 'So even after one, we got a 73% validation accuracy, which is pretty good.', 'start': 972.339, 'duration': 5.203}, {'end': 981.424, 'text': "So let's go ahead and pass in one more epochs equals three.", 'start': 977.562, 'duration': 3.862}, {'end': 984.026, 'text': "Let's do a few more epochs of this data.", 'start': 981.444, 'duration': 2.582}, {'end': 993.124, 'text': 'even better than the last one.', 'start': 991.024, 'duration': 2.1}], 'summary': 'Training achieved 73% validation accuracy after one epoch, aiming for improvement with additional epochs.', 'duration': 45.524, 'max_score': 947.6, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/WvoLTXIjBYU/pics/WvoLTXIjBYU947600.jpg'}, {'end': 1117.734, 'src': 'embed', 'start': 1106.138, 'weight': 9, 'content': [{'end': 1112.146, 'text': 'which is absolutely essential for training models and just kind of analyzing them as they go.', 'start': 1106.138, 'duration': 6.008}, {'end': 1113.588, 'text': "it's super, super useful.", 'start': 1112.146, 'duration': 1.442}, {'end': 1116.572, 'text': "so anyways, that's what we'll be talking about in the next tutorial.", 'start': 1113.588, 'duration': 2.984}, {'end': 1117.734, 'text': 'i will see you there.', 'start': 1116.572, 'duration': 1.162}], 'summary': 'Training and analyzing models is super useful for tutorials.', 'duration': 11.596, 'max_score': 1106.138, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/WvoLTXIjBYU/pics/WvoLTXIjBYU1106138.jpg'}], 'start': 145.074, 'title': 'Convolutional neural networks', 'summary': 'Explains the process of feature extraction using convolution and max pooling, building cnn using tensorflow, and achieving a validation accuracy of 73% after one epoch, with potential to breach 80% after 10 epochs.', 'chapters': [{'end': 292.664, 'start': 145.074, 'title': 'Convolutional neural networks', 'summary': 'Explains the process of extracting features from an image using convolution and max pooling, gradually identifying different shapes and patterns, such as edges, lines, circles, and facial features, within the initial layers of a convolutional neural network.', 'duration': 147.59, 'highlights': ['The process involves extracting features from an image using convolution and max pooling, gradually identifying different shapes and patterns within the initial layers of a convolutional neural network.', 'The most common form of pooling is max pooling, which finds the maximum value within a specified window, such as a 3x3 window.', 'The initial layers in a convolutional neural network are designed to find things like edges, lines, squiggles, circles, and small features, gradually progressing to more complex shapes like faces and eyes.']}, {'end': 504.604, 'start': 292.664, 'title': 'Building convolutional neural network', 'summary': 'Discusses the building of a convolutional neural network using tensorflow, including importing necessary components, normalizing data, and beginning the model construction.', 'duration': 211.94, 'highlights': ['The chapter discusses the process of building a convolutional neural network using TensorFlow, including importing necessary components, normalizing data, and beginning the model construction.', "The neural network was trained on the ImageNet dataset, and the speaker encourages checking out 'A Deep Dream of a Neural Network' and the 'Unconventional Neural Network series' for more interesting projects.", 'The speaker mentions that the easiest way to normalize imagery data is by scaling it, using the maximum and minimum values of the pixel data (255 and 0, respectively), and dividing by 255.', 'The process of importing necessary components for building the convolutional neural network using TensorFlow is detailed, including importing from tensorflow.keras.models and tensorflow.keras.layers.', 'The speaker emphasizes the need to normalize data before feeding it through a neural network, particularly for imagery data, and suggests dividing the data by the maximum value (255) as the easiest way to scale imagery data.']}, {'end': 824.913, 'start': 504.664, 'title': 'Building convolutional neural network', 'summary': 'Covers building a simple sequential model with a 2x64 layer convolutional neural network and a final dense layer of 64 nodes, using rectified linear activation, max pooling, and binary cross entropy loss for cats and dogs classification, compiled with the adam optimizer and accuracy metrics.', 'duration': 320.249, 'highlights': ['The chapter covers building a simple sequential model with a 2x64 layer convolutional neural network and a final dense layer of 64 nodes, using rectified linear activation, max pooling, and binary cross entropy loss for cats and dogs classification, compiled with the Adam optimizer and accuracy metrics.', 'The model starts with a conv2d layer with 64 filters, a 3x3 window, and input shape of 50x50x1, followed by a rectified linear activation and a max pooling 2D layer with a pool size of 2x2.', 'Before adding the final dense layer of 64 nodes, the data is flattened using the flatten layer, and the model is compiled with binary cross entropy loss, the Adam optimizer, and accuracy metrics.']}, {'end': 1117.734, 'start': 824.913, 'title': 'Training model with batch size and validation split', 'summary': 'Discusses the importance of batch size in model fitting, suggesting a range between 20 to 200 for optimal performance, and achieving a validation accuracy of 73% after one epoch, with potential to breach 80% after 10 epochs, with further discussions on interpreting loss and accuracy.', 'duration': 292.821, 'highlights': ['The importance of batch size in model fitting, recommending a range between 20 to 200 for optimal performance and specifying that negative results may occur with a batch size of thousands.', "Achieving a validation accuracy of 73% after one epoch and the potential to breach 80% after 10 epochs, indicating the model's performance and progress.", 'Discussion on interpreting loss and accuracy, emphasizing the significance of validation accuracy over accuracy and identifying patterns during model training.', 'The benefits of tensorboard for training models and analyzing their performance, highlighting its essentiality in the model development process.']}], 'duration': 972.66, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/WvoLTXIjBYU/pics/WvoLTXIjBYU145074.jpg', 'highlights': ['The process involves extracting features from an image using convolution and max pooling, gradually identifying different shapes and patterns within the initial layers of a convolutional neural network.', 'The most common form of pooling is max pooling, which finds the maximum value within a specified window, such as a 3x3 window.', 'The initial layers in a convolutional neural network are designed to find things like edges, lines, squiggles, circles, and small features, gradually progressing to more complex shapes like faces and eyes.', 'The chapter discusses the process of building a convolutional neural network using TensorFlow, including importing necessary components, normalizing data, and beginning the model construction.', "The neural network was trained on the ImageNet dataset, and the speaker encourages checking out 'A Deep Dream of a Neural Network' and the 'Unconventional Neural Network series' for more interesting projects.", 'The speaker mentions that the easiest way to normalize imagery data is by scaling it, using the maximum and minimum values of the pixel data (255 and 0, respectively), and dividing by 255.', 'The chapter covers building a simple sequential model with a 2x64 layer convolutional neural network and a final dense layer of 64 nodes, using rectified linear activation, max pooling, and binary cross entropy loss for cats and dogs classification, compiled with the Adam optimizer and accuracy metrics.', 'The importance of batch size in model fitting, recommending a range between 20 to 200 for optimal performance and specifying that negative results may occur with a batch size of thousands.', "Achieving a validation accuracy of 73% after one epoch and the potential to breach 80% after 10 epochs, indicating the model's performance and progress.", 'The benefits of tensorboard for training models and analyzing their performance, highlighting its essentiality in the model development process.']}], 'highlights': ['Introduction to deep learning tutorial series on classifying dogs versus cats using ConvNets', 'Emphasizing utility of ConvNets with imagery data and converting images to pixel data', 'Explanation of convolution and pooling steps in classifying dogs versus cats', 'Process of extracting features from images using convolution and max pooling', 'Discussion on the initial layers of ConvNets identifying different shapes and patterns', 'Building a convolutional neural network using TensorFlow and model construction', 'Training the neural network on the ImageNet dataset and normalization of imagery data', 'Building a sequential model for cats and dogs classification with specified layers and metrics', 'Importance of batch size in model fitting and its impact on performance', 'Achieving a validation accuracy of 73% after one epoch and potential to breach 80% after 10 epochs', 'Benefits of tensorboard for training models and analyzing performance']}