<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Chethan Hebbar on Medium]]></title>
        <description><![CDATA[Stories by Chethan Hebbar on Medium]]></description>
        <link>https://medium.com/@chethanhebbar.191cs114?source=rss-b7f86cd09379------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Z-aEmaUlgF5HU9uFEfQyCg.jpeg</url>
            <title>Stories by Chethan Hebbar on Medium</title>
            <link>https://medium.com/@chethanhebbar.191cs114?source=rss-b7f86cd09379------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 23:26:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chethanhebbar.191cs114/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Training a CNN to classify images of different Landscapes]]></title>
            <link>https://medium.com/swlh/training-a-cnn-to-classify-images-of-different-landscapes-69511cba7e5b?source=rss-b7f86cd09379------2</link>
            <guid isPermaLink="false">https://medium.com/p/69511cba7e5b</guid>
            <category><![CDATA[convolution-neural-net]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[resnet50]]></category>
            <dc:creator><![CDATA[Chethan Hebbar]]></dc:creator>
            <pubDate>Wed, 01 Jul 2020 05:18:21 GMT</pubDate>
            <atom:updated>2020-07-03T20:22:57.275Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Library used : PyTorch</strong></p><p><strong>The data was taken from the INTEL image classification dataset.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EFmH4NNPkqOlS0Pe" /><figcaption>Photo by <a href="https://unsplash.com/@peter_mc_greats?utm_source=medium&amp;utm_medium=referral">Pietro De Grandi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Welcome to this quick read on how to use <strong>Transfer Learning </strong>to classify various landscape images like the one you see above.</p><p>The dataset can be found on the Kaggle website, link : <a href="https://www.kaggle.com/puneet6060/intel-image-classification"><strong>https://www.kaggle.com/puneet6060/intel-image-classification</strong></a></p><p>The dataset contains three sub-folders:</p><ul><li><strong>seg_train </strong>: The training data that our model will use to learn.</li><li><strong>seg_test </strong>: The validation data to test our model’s accuracy.</li><li><strong>seg_pred</strong> : The data on which we are to make our predictions.</li></ul><p>We are to extract these data and store them into datasets, in order to perform some improvements before converting them to datasets,</p><h3>We use <strong>Data-Augmentation </strong>:</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D6&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D6&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Fchethan0hebbar%2Fprofile_images%2F7e26649e9e2e4f4d99bf127ba2af1b30%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/298159d8d24982dc1da25c6dfa12ca8c/href">https://medium.com/media/298159d8d24982dc1da25c6dfa12ca8c/href</a></iframe><h4>Augmentation :</h4><p>We are now going to transform the data using the torchvision.transforms library.</p><ul><li><strong>Resize() :</strong> We want to uniformly keep all the images in the same dimension, that is <strong>(150, 150)</strong></li><li><strong>ColorJitter() :</strong> We<strong> change certain pixel values</strong> in the 3 channels(red, green, blue) of the image to produce some difference in images which will ultimately lead to the model <strong>generalizing</strong> the data</li><li><strong>RandomHorizontalFlip() : </strong>As the name implies, this transform flips randomly chosen images from the dataset horizontally.</li><li><strong>ToTensor() :</strong> Converts the image from JPEG/JPG format to a tensor.</li><li><strong>Normalize() :</strong> Removes extreme pixel values using the transform: <strong>absolute_value(value — mean) / standard_deviation.</strong></li></ul><p>After applying these transforms, we obtain the datasets, now let’s look at the classes in the data(categories of the image data)</p><h3>Classes:</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D7&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D7&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Fchethan0hebbar%2Fprofile_images%2F7e26649e9e2e4f4d99bf127ba2af1b30%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/23f3e181a8078a223275097a003f1840/href">https://medium.com/media/23f3e181a8078a223275097a003f1840/href</a></iframe><h4>Formation of Data Loaders:</h4><p>After creating the datasets, we separate the data into 150 image tensors for both the training and validation datasets.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D10&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D10&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Fchethan0hebbar%2Fprofile_images%2F7e26649e9e2e4f4d99bf127ba2af1b30%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/068cfd3f44207542eb1a047c141a4c3e/href">https://medium.com/media/068cfd3f44207542eb1a047c141a4c3e/href</a></iframe><p>All the Image Tensors are of dimension : (3, 150, 150)</p><h3>Model Creation :</h3><p>We are going to be using <strong>Transfer Learning</strong> here, as mentioned above. <strong>Transfer Learning is nothing but using a predefined model to fit our data.</strong></p><p>The model used is <strong>ResNet50(Residual Convolutional Neural Network with 50 layers)</strong></p><p>We have our base model which will be called into the final model.</p><p><strong>Base Model:</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D17&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D17&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Fchethan0hebbar%2Fprofile_images%2F7e26649e9e2e4f4d99bf127ba2af1b30%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/595107978bfd0024efb7a125dcda10a4/href">https://medium.com/media/595107978bfd0024efb7a125dcda10a4/href</a></iframe><h4>Convolutional Neural Networks:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*t40b7lyGc-dy6r1_0B_0zQ.jpeg" /><figcaption><strong>Basic CNN</strong></figcaption></figure><p>So CNN has blocks containing 3 important layers:</p><ul><li>Convolutional layer: This layer performs convolution using a kernel of size 3x3(which is equivalent of a weight).</li><li>Pooling Layer : This layer reduces the size of each channel tensor.</li><li>Normalization(ReLU) : The ReLU operation is nothing but,</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/254/1*2-_YrU2R2e1nsOB_r2CxjQ.png" /><figcaption><strong>ReLU function</strong></figcaption></figure><p>These blocks make up the CNN model.</p><h4>Residual Neural Networks:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*nmeqOuZMnCmL7ssVUPAKgA.png" /></figure><p>The difference between these networks is that the ReLU uses the initial input as added inputs to the middle layers as depicted in the figure above.</p><h3>Model Architecture :</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D19&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D19&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Fchethan0hebbar%2Fprofile_images%2F7e26649e9e2e4f4d99bf127ba2af1b30%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/4ee56440af37da5ff314b21da0f7e9f6/href">https://medium.com/media/4ee56440af37da5ff314b21da0f7e9f6/href</a></iframe><p>Freezing the model implies that we<strong> prevent</strong> the layers other than the final fully connected layer from <strong>tweaking/improving the weights in the kernel, </strong>this leads to<strong> only the final layer being trained.</strong></p><p>We will be using the GPU on the KAGGLE Cloud.</p><h3>Training the Model :</h3><p><strong>First, we freeze the model</strong> and train for a bit, and <strong>then unfreezing it and allowing the other layers to train.</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D32&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D32&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Fchethan0hebbar%2Fprofile_images%2F7e26649e9e2e4f4d99bf127ba2af1b30%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/d42fbdd437310f085ef1db8f0708c880/href">https://medium.com/media/d42fbdd437310f085ef1db8f0708c880/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D37&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D37&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Fchethan0hebbar%2Fprofile_images%2F7e26649e9e2e4f4d99bf127ba2af1b30%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/62eca5ba9b5334c4549d2d9659a18a1a/href">https://medium.com/media/62eca5ba9b5334c4549d2d9659a18a1a/href</a></iframe><p>After training the model for a while with different hyper-parameters we get to about <strong><em>92% accuracy.</em></strong></p><h4>Metrics :</h4><p>Let’s look at the accuracy with our training</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D41&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D41&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Fchethan0hebbar%2Fprofile_images%2F7e26649e9e2e4f4d99bf127ba2af1b30%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/edbf7f4e88be6ecc1370511f99e3a9fa/href">https://medium.com/media/edbf7f4e88be6ecc1370511f99e3a9fa/href</a></iframe><p><strong><em>After a while the accuracy flattens out with respect to training time.</em></strong></p><p>What about the loss?</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D44&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D44&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Fchethan0hebbar%2Fprofile_images%2F7e26649e9e2e4f4d99bf127ba2af1b30%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/fa31fe3119f01898cb697c7fdf5e1891/href">https://medium.com/media/fa31fe3119f01898cb697c7fdf5e1891/href</a></iframe><p><strong>The loss also flattens out after a while.</strong></p><p>Now, how does our model do while <strong><em>predicting individual images from seg_pred folder?</em></strong></p><h3>Predictions :</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D54&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D54&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Fchethan0hebbar%2Fprofile_images%2F7e26649e9e2e4f4d99bf127ba2af1b30%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/62385338732b6201f245e5f531827d7b/href">https://medium.com/media/62385338732b6201f245e5f531827d7b/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D56&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D56&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Fchethan0hebbar%2Fprofile_images%2F7e26649e9e2e4f4d99bf127ba2af1b30%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/138cf0f0da7a1a931a660290536c12f6/href">https://medium.com/media/138cf0f0da7a1a931a660290536c12f6/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D58&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Fchethan0hebbar%2Fcourse-project%2Fv%2F2%26cellId%3D58&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Fchethan0hebbar%2Fprofile_images%2F7e26649e9e2e4f4d99bf127ba2af1b30%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/7424768364079cebd88af69986525c48/href">https://medium.com/media/7424768364079cebd88af69986525c48/href</a></iframe><p>Our model is making <strong>great predictions on the seg_pred data</strong>, this is to be expected as our validation accuracy is almost <strong>92%.</strong></p><p>Thank you for reading through this, I will post up a link to my notebook on Kaggle below,</p><p>Check out the notebook for more info <a href="https://www.kaggle.com/chethanhebbar/intel-dataset-project-92-accuracy-pytorch">https://www.kaggle.com/chethanhebbar/intel-dataset-project-92-accuracy-pytorch</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69511cba7e5b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/training-a-cnn-to-classify-images-of-different-landscapes-69511cba7e5b">Training a CNN to classify images of different Landscapes</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>