<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rohit Gupta</title>
    <description>The latest articles on DEV Community by Rohit Gupta (@rohitgupta24).</description>
    <link>https://dev.to/rohitgupta24</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F807251%2Ffefbfdd1-944f-4834-93bd-21ca7a80f2c3.jpg</url>
      <title>DEV Community: Rohit Gupta</title>
      <link>https://dev.to/rohitgupta24</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rohitgupta24"/>
    <language>en</language>
    <item>
      <title>EfficientNet for Beginners</title>
      <dc:creator>Rohit Gupta</dc:creator>
      <pubDate>Wed, 02 Mar 2022 10:46:44 +0000</pubDate>
      <link>https://dev.to/rohitgupta24/efficientnet-for-beginners-24b3</link>
      <guid>https://dev.to/rohitgupta24/efficientnet-for-beginners-24b3</guid>
      <description>&lt;p&gt;A very brief introduction of EfficientNet for beginners without much technical details.&lt;/p&gt;

&lt;p&gt;Considering the problems faced by the older networks, Google released a paper in 2019 that dealt with a new family of CNNs i.e EfficientNet . These CNNs not only provide better accuracy but also improve the efficiency of the models by reducing the parameters and FLOPS (Floating Point Operations Per Second) manifold in comparison to the state of art models&lt;/p&gt;

&lt;p&gt;What is new in this ? : In Efiicient Net : We perform scaling on 1.depth 2. width 3.resolution&lt;/p&gt;

&lt;p&gt;1.Depth Scaling : It means keep on increasing the depth of network. We all know that more layers means more powerful network and hence better results but more layers results in exploding/vanishing gradient problem. To resolve this issue of exploding/vanishing gradient we did have ResNet but ResNet is computationally expensive.&lt;/p&gt;

&lt;p&gt;2.Resolution Scaling : Low resolution images are mostly blurry. High Reso has more pixel and has more info. Network learns on more complex features and fine grained patterns. Learning gets better and accuracy increases.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JMfC3XPU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ly6n9zyxyi6plzbjmk7x.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JMfC3XPU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ly6n9zyxyi6plzbjmk7x.jpg" alt="Image description" width="474" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3.Width : Increasing number of Feature Maps/ Channels. Increasing the number of feature maps. To get each and every feature of image, we need more feature maps. More fine grained features needed to be extracted.&lt;/p&gt;

&lt;p&gt;If the input image is bigger(resolution), than there is more complex features and fine-grained patterns.&lt;/p&gt;

&lt;p&gt;Why Depth Scaling : we have done Resolution Scaling, hence we have more data or more information in our input image which needs to be processed. So we need more layers.&lt;/p&gt;

&lt;p&gt;But how much Depth Scaling for particular increment in the resolution of images? How many layers we need ?&lt;/p&gt;

&lt;p&gt;Also from the paper :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;1.Scaling up any dimension of network width, depth or resolution improves accuracy but the accuracy gain diminishes for bigger models.&lt;/p&gt;

&lt;p&gt;2.In order to pursue better accuracy and efficiency, it is critical to balance all dimensions of network width, depth and resolution during scaling.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The main contributions of this paper are: a.Designing a simple mobile-size baseline architecture: EfficientNet-B0 b.Providing an effective compound scaling method for increasing the model size to achieve maximum accuracy gains.&lt;/p&gt;

&lt;p&gt;How to do Scaling in the balanced way ? Compound Scaling helps in choosing the right value so that accuracy gains didn't diminishes. For Compound Scaling, we need a baseline model (Efficientnet-B0). Before continuing, we should know that EfficientNet-B0 is developed by &lt;a href="https://en.wikipedia.org/wiki/Neural_architecture_search"&gt;Neural Architecture Search&lt;/a&gt; which is used for automating the design of ANNs and the networks designed by NAS are on par and outperform hand designed architectures.&lt;/p&gt;

&lt;p&gt;EfficientNet-B0. It achieves 77.3% accuracy on ImageNet with only 5.3M parameters and 0.39B FLOPS. (Resnet-50 provides 76% accuracy with 26M parameters and 4.1B FLOPS).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4Yw_SoEk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/am18sc12pavf61l9dhis.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4Yw_SoEk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/am18sc12pavf61l9dhis.jpg" alt="Image description" width="880" height="694"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JEfM2zdr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tb2xnjequym3b78exy6v.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JEfM2zdr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tb2xnjequym3b78exy6v.jpg" alt="Image description" width="880" height="182"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On Efficientnet-B0, we will do Compound Scaling, to upscale the methods. Compound Scaling is done in the following way:&lt;/p&gt;

&lt;p&gt;STEP 1: we first fix φ = 1, assuming twice more resources available, and do a small grid search of α, β, γ (by using equations 1 and 2 given in paper). In particular, we find the best values for EfficientNet-B0 are α = 1.2, β =1.1, γ = 1.15, under constraint of&lt;br&gt;
α ·β2· γ2 ≈ 2&lt;/p&gt;

&lt;p&gt;• STEP 2: we then fix α, β, γ as constants and scale up baseline network with different φ using Equation 3, to obtain EfficientNet-B1 to B7. Notably, it is possible to achieve even better performance by searching for α, β, γ directly around a large model, but the search cost becomes prohibitively more expensive on larger models. Our method solves this issue by only doing search once on the small baseline network (step 1), and then use the same scaling coefficients for all other models (step 2)&lt;/p&gt;

&lt;p&gt;α = 1.2, β =1.1, γ = 1.15 simply means that if resolution is enhanced by 15%, than depth should be increased by 20% and width should be increased by 10%.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Results&lt;/u&gt;:This technique allowed the authors to produce models that provided accuracy higher than the existing ConvNets and that too with a monumental reduction in overall FLOPS and model size.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://arxiv.org/pdf/1905.11946.pdf"&gt;Original Paper&lt;/a&gt;&lt;br&gt;
&lt;a href="https://ai.googleblog.com/2019/05/efficientnet-improving-accuracy-and.html"&gt;Google Blog&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all folks.&lt;/p&gt;

&lt;p&gt;If you have any doubt ask me in the comments section and I'll try to answer as soon as possible.&lt;br&gt;
If you love the article follow me on Twitter: [&lt;a href="https://twitter.com/guptarohit_kota"&gt;https://twitter.com/guptarohit_kota&lt;/a&gt;]&lt;br&gt;
If you are the Linkedin type, let's connect: &lt;a href="http://www.linkedin.com/in/rohitgupta24"&gt;www.linkedin.com/in/rohitgupta24&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy Coding and Have an awesome day ahead 😀!&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>deeplearning</category>
      <category>neuralnetwork</category>
      <category>python</category>
    </item>
    <item>
      <title>ConvNext : A ConvNet for the 2020s (Part I)</title>
      <dc:creator>Rohit Gupta</dc:creator>
      <pubDate>Mon, 28 Feb 2022 13:10:44 +0000</pubDate>
      <link>https://dev.to/rohitgupta24/convnext-a-convnet-for-the-2020s-part-i-i43</link>
      <guid>https://dev.to/rohitgupta24/convnext-a-convnet-for-the-2020s-part-i-i43</guid>
      <description>&lt;p&gt;The goal of the paper is to modernize the ResNet and bring back the glory to CNNs ;)&lt;br&gt;
In other words, they tried to apply the concepts of Transformers to ResNet like archtitecture and make them better. They individually applied ideas and showcased how much of an improvement it shows.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kk2HJ117--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dicydgyvhytymzo9inwn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kk2HJ117--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dicydgyvhytymzo9inwn.png" alt="Image description" width="562" height="680"&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;They compared the impact on 2 things : &lt;strong&gt;Accuracy&lt;/strong&gt; and &lt;strong&gt;Computation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Finally they reached the conclusion that following Changes enhances the results : &lt;/p&gt;

&lt;p&gt;&lt;em&gt;-Large Kernel Size(7*7).&lt;br&gt;
-Replace ReLu with GeLu&lt;br&gt;
-Fewer Norm Layers&lt;br&gt;
-Substitute BatchNorm with LayerNorm&lt;br&gt;
-Inverted Block&lt;br&gt;
-Grouped Convs reduces computation&lt;br&gt;
-Add a "patchify layer"(to split an image into sequence of patches)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Below Image shows the comparison of ResNet, ViT with ConvNext. Diameter shows the Computation Power needed, hence more bigger the circle is, more computationally expensive model will be.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g7o7OLwP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rt8kunoulq41i1usb134.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g7o7OLwP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rt8kunoulq41i1usb134.png" alt="Image description" width="576" height="545"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If augmentationare applied on ViT model, than comparison goes like this :&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MqicUpSu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e6zgfmq35na71og58bk9.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MqicUpSu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e6zgfmq35na71og58bk9.jpg" alt="Image description" width="880" height="836"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A vanilla ViT, on the other hand, faces difficulties when applied to general computer vision tasks such as object detection and semantic segmentation. It is the hierarchical Transformers (e.g., Swin Transformers) that reintroduced several ConvNet priors, making Transformers practically viable as a generic vision backbone and demonstrating remarkable performance on a wide variety of vision tasks. However, the effectiveness of such hybrid approaches is still largely credited to the intrinsic superiority of Transformers, rather than the inherent inductive biases of convolutions. In this work, we reexamine the design spaces and test the limits of what a pure ConvNet can achieve. We gradually “modernize” a standard ResNet toward the design of a vision Transformer, and discover several key components that contribute to the performance difference along the way. The outcome of this&lt;br&gt;
exploration is a family of pure ConvNet models dubbed ConvNeXt.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Also, another quote from paper is very good :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The full dominance of ConvNets in computer vision was&lt;br&gt;
not a coincidence: in many application scenarios, a “sliding&lt;br&gt;
window” strategy is intrinsic to visual processing, particularly when working with high-resolution images. ConvNets have several built-in inductive biases that make them well suited to a wide variety of computer vision applications. The most important one is translation equivariance, which is a desirable property for tasks like objection detection. ConvNets are also inherently efficient due to the fact that when used in a sliding-window manner, the computations are shared.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Translational Equivariance or just equivariance is a very important property of the convolutional neural networks where the position of the object in the image should not be fixed in order for it to be detected by the CNN. This simply means that if the input changes, the output also changes.&lt;br&gt;
The property of translational equivariance is achieved in CNN’s by the concept of weight sharing. As the same weights are shared across the images, hence if an object occurs in any image it will be detected irrespective of its position in the image. This property is very useful for applications such as image classification, object detection, etc where there may be multiple occurrences of the object or the object might be in motion.&lt;/p&gt;

&lt;p&gt;For more information on Translational Equivariance : &lt;a href="https://towardsdatascience.com/translational-invariance-vs-translational-equivariance-f9fbc8fca63a"&gt;Follow this Article&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Details of Paper&lt;/strong&gt; :&lt;br&gt;
ResNet-50 is trained like Transformers but with 1.More Epochs,2.Image Augmentation,and 3.AdamW.&lt;br&gt;
Researchers used a training recipe that is close to DeiT’s and&lt;br&gt;
Swin Transformer’s. The training is extended to 300 epochs from the original 90 epochs for ResNets. We use the AdamW optimizer, data augmentation techniques such as Mixup, Cutmix, RandAugment, Random Erasing, and regularization schemes including Stochastic Depth and Label Smoothing.&lt;/p&gt;

&lt;p&gt;Adding Patchify Layer :  Researchers have replaced the ResNet-style stem cell with a patchify layer implemented using a 4×4, stride 4 convolutional layer. The accuracy has changed from 79.4% to 79.5%. This suggests that the stem cell in a ResNet may be substituted with a simpler “patchify” layer like ViT.&lt;/p&gt;

&lt;p&gt;ResNeXt-ify : The use of depthwise convolution effectively reduces the network FLOPs and, as expected, the accuracy. Following the strategy proposed in ResNeXt, we increase the network width to the same number of channels as Swin-T’s (from 64 to 96).This brings the network performance to 80.5% with increased FLOPs.&lt;/p&gt;

&lt;p&gt;More to come soon.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://arxiv.org/abs/2201.03545"&gt;Official Paper Link&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=xuY20JgrVII"&gt;Awesome Video Explanation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all folks.&lt;/p&gt;

&lt;p&gt;If you have any doubt ask me in the comments section and I'll try to answer as soon as possible.&lt;br&gt;
If you love the article follow me on Twitter: [&lt;a href="https://twitter.com/guptarohit_kota"&gt;https://twitter.com/guptarohit_kota&lt;/a&gt;]&lt;br&gt;
If you are the Linkedin type, let's connect: &lt;a href="http://www.linkedin.com/in/rohitgupta24"&gt;www.linkedin.com/in/rohitgupta24&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy Coding and Have an awesome day ahead 😀!&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>deeplearning</category>
      <category>computervision</category>
      <category>cnn</category>
    </item>
    <item>
      <title>Cross Validation for Beginners</title>
      <dc:creator>Rohit Gupta</dc:creator>
      <pubDate>Sat, 26 Feb 2022 20:44:01 +0000</pubDate>
      <link>https://dev.to/rohitgupta24/cross-validation-5gm3</link>
      <guid>https://dev.to/rohitgupta24/cross-validation-5gm3</guid>
      <description>&lt;p&gt;While attempting to solve a ML problem, we do a train_test split. If this split is done randomly than it might be possible that some dataset might be completely present in test set and absent from training set or vice versa. This reduces the accuracy of model. So Cross Validation comes into picture.&lt;br&gt;
Cross-validation is a step in the process of building a machine learning model which helps us ensure that our models fit the data accurately and also ensures that we do not overfit.Cross-validation is dividing training data into a few parts. We train the model on some of these parts and test on the remaining parts.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;Types Of Cross Validation&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;i. &lt;strong&gt;Leave One Out CV&lt;/strong&gt; :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Split a dataset into a training set and a testing set, using   all but one observation as part of the training set.&lt;/li&gt;
&lt;li&gt;Note that we only leave one observation “out” from the training set. This is where the method gets the name “leave-one-out” cross-validation.&lt;/li&gt;
&lt;li&gt;Use "Leave One Out" as test set. &lt;/li&gt;
&lt;li&gt;In the second experiment, "leave out" another set and take the rest of the data as training input.&lt;/li&gt;
&lt;li&gt;Repeat the Process.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Cons&lt;/u&gt; : Computationally Expensive and results in Low Bias.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Low Bias&lt;/u&gt; : For the training and test set, we will get good results but when we will try the model on new data accuracy will go low and error rate goes high.&lt;/p&gt;

&lt;p&gt;ii. &lt;strong&gt;K-Fold CV&lt;/strong&gt; : We have some data and we have k value. For example : number of data == 1000 and k == 5. Hence first 200 samples(1000/5 = 200) will be test data. In second experiment, next 200 will be test data. Process will be iterated for 5 times.&lt;br&gt;
Out of all the 5 iterations, we will get 5 accuracies and we can select the best out of 5.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/rohitgupta24/tidbits/blob/main/cross_validation.py"&gt;Full Code&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pandas as pd
from sklearn import model_selection
if __name__ == "__main__":
# Training data is in a CSV file called train.csv
    df = pd.read_csv("train.csv")
    # we create a new column called kfold and fill it with -1
    df["kfold"] = -1
    # the next step is to randomize the rows of the data
    df = df.sample(frac=1).reset_index(drop=True)
    # initiate the kfold class from model_selection module
    kf = model_selection.KFold(n_splits=5)
    # fill the new kfold column
    for fold, (trn_, val_) in enumerate(kf.split(X=df)):
        df.loc[val_, 'kfold'] = fold
    # save the new csv with kfold column
    df.to_csv("train_folds.csv", index=False)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;iii. &lt;strong&gt;Stratified CV&lt;/strong&gt; : If we have a skewed dataset for classification with 90% positive samples and only 10% negative samples, we don't use random k-fold cross-validation. Using simple k-fold cross-validation for a dataset like this can result in folds with all negative samples. In these cases, we prefer using stratified k-fold cross-validation.&lt;br&gt;
Stratified k-fold cross-validation keeps the ratio of labels in each fold constant. So, in each fold, we will have the same 90% positive and 10% negative samples. Stratified k-fold cross-validation keeps the ratio of labels in each fold constant.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pandas as pd
from sklearn import model_selection
if __name__ == "__main__":
# Training data is in a CSV file called train.csv
    df = pd.read_csv("train.csv")
    # we create a new column called kfold and fill it with -1
    df["kfold"] = -1
    # the next step is to randomize the rows of the data
    df = df.sample(frac=1).reset_index(drop=True)
    # initiate the kfold class from model_selection module
    kf = model_selection.KFold(n_splits=5)
    # fill the new kfold column
    for fold, (trn_, val_) in enumerate(kf.split(X=df)):
        df.loc[val_, 'kfold'] = fold
    # save the new csv with kfold column
    df.to_csv("train_folds.csv", index=False)`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;iv. &lt;strong&gt;Time Series CV&lt;/strong&gt; : The method that can be used for cross-validating the time-series model is cross-validation on a rolling basis. Start with a small subset of data for training purpose, forecast for the later data points and then checking the accuracy for the forecasted data points. The same forecasted data points are then included as part of the next training dataset and subsequent data points are forecasted.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m9Pn48OI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zvxnnejhqnrxfii5u7qs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m9Pn48OI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zvxnnejhqnrxfii5u7qs.png" alt="Image description" width="602" height="276"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/rohitgupta24/tidbits/blob/main/cross_validation.py"&gt;Full Code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all folks.&lt;/p&gt;

&lt;p&gt;If you have any doubt ask me in the comments section and I'll try to answer as soon as possible.&lt;br&gt;
If you love the article follow me on Twitter: [&lt;a href="https://twitter.com/guptarohit_kota"&gt;https://twitter.com/guptarohit_kota&lt;/a&gt;]&lt;br&gt;
If you are the Linkedin type, let's connect: &lt;a href="http://www.linkedin.com/in/rohitgupta24"&gt;www.linkedin.com/in/rohitgupta24&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy Coding and Have an awesome day ahead 😀!&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>python</category>
      <category>deeplearning</category>
      <category>datascience</category>
    </item>
    <item>
      <title>Positional Embeddings</title>
      <dc:creator>Rohit Gupta</dc:creator>
      <pubDate>Fri, 25 Feb 2022 07:14:21 +0000</pubDate>
      <link>https://dev.to/rohitgupta24/positional-embeddings-3m89</link>
      <guid>https://dev.to/rohitgupta24/positional-embeddings-3m89</guid>
      <description>&lt;p&gt;&lt;strong&gt;Positional Embeddings&lt;/strong&gt; always looked like a different thing to me, so this post is all about explaining the same in &lt;u&gt;plain english.&lt;/u&gt;.&lt;br&gt;
We all hear and read this word ("Positional Embeddings") wherever Transformer Neural Network comes up and now as Transformers are everywhere from Natural Language Processing to Image Classification(after &lt;a href="https://dev.to/rohitgupta24/vision-transformer-an-image-is-worth-1616-words-3o2g"&gt;ViT&lt;/a&gt;), it becomes more important to understand them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are Positional Embeddings or Positional Encodings?&lt;/strong&gt;&lt;br&gt;
Let's take an example : Consider the input as "King and Queen". Now if we change the order of the input as ""Queen and King", than the meaning of the  input might get change. Same happens if the input is in the form of 16*16 images(as it happens in &lt;a href="https://dev.to/rohitgupta24/vision-transformer-an-image-is-worth-1616-words-3o2g"&gt;ViT&lt;/a&gt;), if order of images changes, than everything changes.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m1ewFKve--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/11j9u57l66m8v6agp0wf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m1ewFKve--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/11j9u57l66m8v6agp0wf.png" alt="Input in right sequence" width="880" height="345"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--I-EtjuPD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iiw4tikrj0vi4dmiy13x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--I-EtjuPD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iiw4tikrj0vi4dmiy13x.png" alt="Input in Distorted Sequence" width="880" height="385"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, the transformer doesn't process the input sequentially, Input is processed in parallel.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pg9Sm4R2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/isr0bti9hmmabvycwhio.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pg9Sm4R2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/isr0bti9hmmabvycwhio.png" alt="Image description" width="880" height="586"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4pyPrrBd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/79hrtjsbg2lf889ajdmh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4pyPrrBd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/79hrtjsbg2lf889ajdmh.png" alt="Image description" width="880" height="542"&gt;&lt;/a&gt; For each element it combines the information from the other element through self-attention, but each element does this aggregation on its own independently of what other elements do.&lt;br&gt;
The Transformer model doesn't model the sequence of input anywhere explicitly. So to know the exact sequence of input &lt;strong&gt;Positional Embeddings&lt;/strong&gt; comes into picture. They works as the hints to Transformers and tells the model about the sequence of inputs.&lt;/p&gt;

&lt;p&gt;These embeddings are added to initial vector representations of the input.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Jj0HUQKS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ii5j01e0jr37c2p8taxx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Jj0HUQKS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ii5j01e0jr37c2p8taxx.png" alt="Image description" width="880" height="250"&gt;&lt;/a&gt; Also,Every position have same identifier irrespective of what exactly the input is.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AUpn9oCq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ivgz6z9d14wkginb4kku.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AUpn9oCq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ivgz6z9d14wkginb4kku.png" alt="Image description" width="880" height="317"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TdO4s0oz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mycbcluij0o78ghmgeyb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TdO4s0oz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mycbcluij0o78ghmgeyb.png" alt="Image description" width="880" height="341"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is no notion of word order (1st word, 2nd word, ..) in the initial architecture. All words of input sequence are fed to the network with no special order or position; in contrast, in RNN architecture, n-th word is fed at step n, and in ConvNet, it is fed to specific input indices. Therefore model has no idea how the words are ordered. Consequently, a position-dependent signal is added to each word-embedding to help the model incorporate the order of words. Based on experiments, this addition not only avoids destroying the embedding information but also adds the vital position information.&lt;/p&gt;

&lt;p&gt;The specific choice of (sin, cos) pair helps the model in learning patterns that rely on relative positions. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Further Reading:&lt;/strong&gt; &lt;a href="http://jalammar.github.io/illustrated-transformer/"&gt;Article by Jay Alammar&lt;/a&gt; explains the paper with excellent visualizations. &lt;br&gt;
The example on positional encoding calculates PE(.)the same, with the only difference that it puts sin in the first half of embedding dimensions (as opposed to even indices) and cos in the second half (as opposed to odd indices). This difference does not matter since vector operations would be invariant to the permutation of dimensions.&lt;/p&gt;

&lt;p&gt;This article is inspired by &lt;a href="https://www.youtube.com/watch?v=1biZfFLPRSY"&gt;this Youtube Video from AI Coffee Break with Letitia&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all folks.&lt;/p&gt;

&lt;p&gt;If you have any doubt ask me in the comments section and I'll try to answer as soon as possible.&lt;br&gt;
If you love the article follow me on Twitter: [&lt;a href="https://twitter.com/guptarohit_kota"&gt;https://twitter.com/guptarohit_kota&lt;/a&gt;]&lt;br&gt;
If you are the Linkedin type, let's connect: &lt;a href="http://www.linkedin.com/in/rohitgupta24"&gt;www.linkedin.com/in/rohitgupta24&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have an awesome day ahead 😀!&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>transformer</category>
      <category>neuralnetwork</category>
      <category>deeplearning</category>
    </item>
    <item>
      <title>Vision Transformer : An image is worth 16*16 words</title>
      <dc:creator>Rohit Gupta</dc:creator>
      <pubDate>Thu, 24 Feb 2022 12:34:13 +0000</pubDate>
      <link>https://dev.to/rohitgupta24/vision-transformer-an-image-is-worth-1616-words-3o2g</link>
      <guid>https://dev.to/rohitgupta24/vision-transformer-an-image-is-worth-1616-words-3o2g</guid>
      <description>&lt;p&gt;In computer vision, however, convolutional architectures remain dominant. Inspired by NLP successes, multiple works try combining CNN-like architectures with self-attention, some replacing the convolutions entirely. The latter models, while theoretically efficient, have not yet been scaled effectively on modern hardware accelerators due to the use of specialized attention patterns.&lt;br&gt;
Inspired by the Transformer scaling successes in NLP,in this research paper a standard Transformer was applied directly to images, with the fewest possible modifications  &lt;a href="https://arxiv.org/abs/2010.11929" rel="noopener noreferrer"&gt;An Image is worth 16 x 16 Words&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;When pre-trained on large amounts of data and transferred to multiple mid-sized or small image recognition benchmarks&lt;br&gt;
(ImageNet, CIFAR-100,VTAB, etc.), Vision Transformer (ViT) attains excellent results compared to state-of-the-art convolutional networks while requiring substantially fewer computational resources to train.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In particular, the best model reaches the accuracy of 88.55% on ImageNet, 90.72% on ImageNet-ReaL, 94.55% on CIFAR-100, and 77.63% on the VTAB suite of 19 tasks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem with CNN&lt;/strong&gt;:&lt;br&gt;
CNNs use kernels to aggregate very local information in each layer which than is passed to next layer which again use kernels to aggregate the local information.Hence CNN starts to look very locally. But Vision transformer resolved this problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How Transformers resolves it?&lt;/strong&gt;&lt;br&gt;
It considers a very large field of view from the very beginning. It overcomes the limitation of CNNs that looked very narrowly at first.Also, there is no decoder layer, instead there is an extra linear layer for the final classification called the MLP head.&lt;br&gt;
The Transformer look at the data by taking an input image and splitting it into patches of 16*16 pixels.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffw50s5gx34856ha2mmyx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffw50s5gx34856ha2mmyx.png" alt="Input Image"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjl2041831cziahqchvai.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjl2041831cziahqchvai.png" alt="Input images splitted into 16*16 patches"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All the patches are treated as simple tokensand are than flattened and lower dimensional linear embeddings are produced.&lt;br&gt;
Than we add positional embeddings to the vector. Now this sequence is feeded into standard transformer encoder.&lt;br&gt;
Model is pretrained with image labels.(fully supervised huge dataset.)&lt;br&gt;
Finally, network is finetuned on the downstream dataset.&lt;/p&gt;

&lt;p&gt;While resolving a NLP problem, input(like incomplete sentences) are first converted into numeric indices(by creating a vocabulary dictionary from the words present in training data) and then are fed into Transformers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Positional Embedding&lt;/strong&gt; :Positional encoding is a re-representation of the values of a word and its position in a sentence (given that is not the same to be at the beginning that at the end or middle).&lt;br&gt;
But you have to take into account that sentences could be of any length, so saying '"X" word is the third in the sentence' does not make sense if there are different length sentences: 3rd in a 3-word-sentence is completely different to 3rd in a 20-word-sentence.&lt;br&gt;
What a positional encoder does is to get help of the cyclic nature of sin(x) and cos(x) functions to return information of the position of a word in a sentence.&lt;br&gt;
&lt;a href="https://datascience.stackexchange.com/questions/51065/what-is-the-positional-encoding-in-the-transformer-model" rel="noopener noreferrer"&gt;Source : stackexchange.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In all&lt;/strong&gt;, total 3 variants of &lt;strong&gt;ViT&lt;/strong&gt;were proposed &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F59sit7bukykinkfdp2g1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F59sit7bukykinkfdp2g1.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Hidden size D is the embedding size, which is kept fixed throughout the layers. &lt;br&gt;
Transformers are better in general because they can be scaled up.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ful6gzzvyuq28ueiumsed.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ful6gzzvyuq28ueiumsed.png" alt="Image description"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problems which still need to be resolved&lt;/strong&gt;&lt;br&gt;
Transformers are unfocused in the initial epochs but later become focused to make write predictions after some training and therefore are more data hungry than CNNs.&lt;br&gt;
Transformers find out very original and unexpected ways to look into data(input images) as there is no element in the architecture to tell the model how to do that exactly.However, CNNs are focussed on local view from the beginning by the convolutions.&lt;/p&gt;

&lt;p&gt;Transformers lack the inductive biases of Convolutional Neural Networks (CNNs), such as translation invariance and a locally restricted receptive field. Invariance means that you can recognize an entity (i.e. object) in an image, even when its appearance or position varies. Translation in computer vision implies that each image pixel has been moved by a fixed amount in a particular direction&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
The key takeaway of this work is the formulation of an image classification problem as a sequential problem by using image patches as tokens, and processing it by a Transformer. That sounds good and simple but it needs massive data and very high computational power. If ViT is trained on datasets with more than 14M images it can approach or beat state-of-the-art CNNs.&lt;/p&gt;

&lt;p&gt;Further Reading : &lt;a href="https://arxiv.org/abs/2010.11929" rel="noopener noreferrer"&gt;Official Paper&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all folks.&lt;/p&gt;

&lt;p&gt;If you have any doubt ask me in the comments section and I'll try to answer as soon as possible.&lt;br&gt;
If you love the article follow me on Twitter: [&lt;a href="https://twitter.com/guptarohit_kota" rel="noopener noreferrer"&gt;https://twitter.com/guptarohit_kota&lt;/a&gt;]&lt;br&gt;
If you are the Linkedin type, let's connect: &lt;a href="http://www.linkedin.com/in/rohitgupta24" rel="noopener noreferrer"&gt;www.linkedin.com/in/rohitgupta24&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have an awesome day ahead 😀!&lt;/p&gt;

</description>
      <category>deeplearning</category>
      <category>machinelearning</category>
      <category>neuralnetworks</category>
      <category>computervision</category>
    </item>
    <item>
      <title>ResNet For Begginers</title>
      <dc:creator>Rohit Gupta</dc:creator>
      <pubDate>Sat, 19 Feb 2022 07:51:00 +0000</pubDate>
      <link>https://dev.to/rohitgupta24/resnet-for-begginers-2b6e</link>
      <guid>https://dev.to/rohitgupta24/resnet-for-begginers-2b6e</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;u&gt;What was the Problem&lt;/u&gt;&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;When AlexNet won the ImageNet 2012 competition, every one started using more layers in a deep neural network to reduce the error rate. This works for less number of layers, but when we increase the number of layers, there is a common problem arises with it called Vanishing/Exploding gradient. This causes the gradient to become 0 or too large. Thus when we increases number of layers, the training rate decreases only upto a limit and than start increasing.&lt;/p&gt;

&lt;p&gt;However in theory, with increase in number of layers, performance of neural network should increase.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KNdfYnyQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q6b46oi6f74k0tjor73n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KNdfYnyQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q6b46oi6f74k0tjor73n.png" alt="graph of training error vs number of layers" width="880" height="686"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  *&lt;em&gt;&lt;u&gt;How ResNet solved the Problem&lt;/u&gt;&lt;/em&gt;*
&lt;/h2&gt;

&lt;p&gt;ResNet used the concept of "Skip Connections" and obviously it worked ;)&lt;br&gt;
For example, consider there are two neural networks as shown in image.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LdDRSJV9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/redsum33cabiv6j4rapq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LdDRSJV9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/redsum33cabiv6j4rapq.png" alt="Image description" width="696" height="755"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the first neural network, output is &lt;strong&gt;f(x)&lt;/strong&gt; and there is no problem of vanishing or exploding gradient as the number of layers are less. &lt;br&gt;
And we know that when we will increase the number of layers, output will be changed and this output will not be efficient due to the exploding and vanishing gradient.&lt;br&gt;
Now, in the second neural network (which is deeper, as shown in image), we have added some more layers and due to these layers our output is changed to &lt;strong&gt;y = b + f(x)&lt;/strong&gt; from &lt;strong&gt;f(x)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;In the second output, if somehow we would be able to make b = 0, than &lt;br&gt;
                      **y = 0 + f(x)**&lt;/code&gt;&lt;br&gt;
In this way, we would be able to make the neural network more deeper, hence we will get more efficient model and also as we are getting the same output(as of shallow network) so there is no effect of vanishing or exploding gradient.&lt;/p&gt;

&lt;p&gt;Or in other words, we can say that if input(of the extra layers which we have added to convert shallow network into deeper network) == output than we will get the desired results.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Main idea behind Residual Network is to make b = 0 , so that y=f(x), for deeper neural networks&lt;br&gt;
In shallow network: y = f(x)&lt;br&gt;
In deeper network:&lt;br&gt;
   If operations of extra layers = b,&lt;br&gt;
   than :&lt;br&gt;
          y = f(x) + b&lt;br&gt;
          y = f(x) + 0        [b = 0]&lt;br&gt;
   Input of extra layers = Output of Extra Layers (b = 0)&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;u&gt;ResNet Architecture&lt;/u&gt;&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QJDVuWQZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6kng3crckj851ezlb3pr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QJDVuWQZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6kng3crckj851ezlb3pr.png" alt="Image description" width="880" height="481"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;u&gt;How to read ResNet 50&lt;/u&gt;&lt;/em&gt; : Convolution operation is done on input image with the filter of size 7*7 and 64 such Filters with stride of 2 and padding of 3.&lt;br&gt;
And than MaxPooling Layer is applied with filter size of 3*3 and stride of 2 and then other operations are applied as shown in image.&lt;/p&gt;

&lt;p&gt;Dotted line shows the Convolution Block in Skip Connections.&lt;/p&gt;

&lt;p&gt;There are two types of Blocks in ResNet :&lt;br&gt;
a. Identity Block : where input size == output size. Hence there will be no Convolution Layer in Skip Connection.&lt;/p&gt;

&lt;p&gt;Example : input image = 56*56*3  --&amp;gt; output image = 56*56*3 &lt;/p&gt;

&lt;p&gt;b. Convolution Block : where input size of image != output size. Hence there will be a Convolution Layer in the skip connection.&lt;/p&gt;

&lt;p&gt;Example : input image = 56*56*3  --&amp;gt; output image = 28*28*128&lt;/p&gt;

&lt;p&gt;To make the input == output, we can do two operations.        Padding or 1*1 Convolution.&lt;/p&gt;

&lt;p&gt;(Convolution of 1*1): (n+2p-f/s)+1 : Padding = 0, hence we get image of size : 28*28&lt;br&gt;
And that's how after performing 1*1 Convolution, input == output.&lt;/p&gt;

&lt;p&gt;What's Next :&lt;br&gt;
 Coding ResNet&lt;br&gt;
 ResNext : &lt;a href="https://arxiv.org/abs/1611.05431v2"&gt;https://arxiv.org/abs/1611.05431v2&lt;/a&gt;&lt;br&gt;
 SeResNext : &lt;a href="https://arxiv.org/abs/1709.01507v4"&gt;https://arxiv.org/abs/1709.01507v4&lt;/a&gt;&lt;br&gt;
 Original ResNet Paper : [&lt;a href="https://arxiv.org/pdf/1512.03385v1.pdf"&gt;https://arxiv.org/pdf/1512.03385v1.pdf&lt;/a&gt;]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;That's all folks.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you have any doubt ask me in the comments section and I'll try to answer as soon as possible.&lt;/p&gt;

&lt;p&gt;If you love the article follow me on Twitter: [&lt;a href="https://twitter.com/guptarohit_kota"&gt;https://twitter.com/guptarohit_kota&lt;/a&gt;]&lt;br&gt;
If you are the Linkedin type, let's connect: &lt;a href="http://www.linkedin.com/in/rohitgupta24"&gt;www.linkedin.com/in/rohitgupta24&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have an awesome day ahead 😀!&lt;/p&gt;

</description>
      <category>resnet</category>
      <category>deeplearning</category>
      <category>resnext</category>
      <category>neuralnetwork</category>
    </item>
  </channel>
</rss>
