<?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 Sheng Fang on Medium]]></title>
        <description><![CDATA[Stories by Sheng Fang on Medium]]></description>
        <link>https://medium.com/@shengfang?source=rss-e19717fcc1a2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*O9yxAIyvHWKtGxMRgzP3Dw.png</url>
            <title>Stories by Sheng Fang on Medium</title>
            <link>https://medium.com/@shengfang?source=rss-e19717fcc1a2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 16:30:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shengfang/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[Review of LeNet-5: How to design the architecture of CNN]]></title>
            <link>https://medium.com/data-science/review-of-lenet-5-how-to-design-the-architecture-of-cnn-8ee92ff760ac?source=rss-e19717fcc1a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ee92ff760ac</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[convolutional-network]]></category>
            <category><![CDATA[design-model]]></category>
            <category><![CDATA[image-classification]]></category>
            <dc:creator><![CDATA[Sheng Fang]]></dc:creator>
            <pubDate>Mon, 20 Apr 2020 15:17:17 GMT</pubDate>
            <atom:updated>2020-04-23T13:58:31.618Z</atom:updated>
            <content:encoded><![CDATA[<h4>Incorporate knowledge to tailor the architecture of CNN</h4><p>This post is a review of an old, difficult, and inspiring paper: <strong>Gradient-Based Learning Applied to Document Recognition</strong>”[1] by Yann LeCun as the first author. You can find many reviews of this paper. Most of them only focus on the architecture of the Convolution Neural Network (<em>CNN</em>) LeNet-5. However, I’d like to talk about some other interesting points:</p><ol><li>The concept of globally trainable system from the perspective of back-propagation</li><li>How to incorporate knowledge during the design of a neural network</li></ol><p>In fact, there are 2 networks mentioned in this paper. The first one is <em>CNN</em>, named LeNet-5 and the second one is called Graph Transformer Network (<em>GTN</em>). I talk only about the LeNet-5 in this post.</p><h3>1. Globally trainable system</h3><h3>What’s a globally trainable system?</h3><p>A system usually includes several modules. From the perspective of back-propagation, if all the modules are differentiable and the connections between the modules are also differential, in other words, the back propagation of gradients can go back from the loss function at the end to the input, it is a globally trainable system. Sometimes, we also name it as end-to-end solution for machine learning problem.</p><p>Let me give an example: we want to mark the gender of all the faces in one image? First solution is to detect the positions of all the faces and then classify the gender with the sub-image with one face. Second solution is to create a model, which takes the image as input and outputs the localization of faces as well as the corresponding gender. In the first solution, the error from the localization influence the performance of the gender classification. But we can’t use the loss function of gender classification to optimize the performance of localization if the 2 modules are separate. In the second end-to-end solution, the localization and gender detection are globally optimized.</p><h3>What’s the advantage of a globally trainable system?</h3><p>As partially mentioned before, we optimize all the modules together. If we have enough data, the system can achieve better performance relative to the non-globally-trainable-system.</p><p>Another more important advantage is: let the machine learn from data. If you are familiar with <em>CNN</em>, you probably hear that the first several hidden layers of CNN can learn the strong local pattern of image. Here are some examples in Image 1 from paper<a href="https://sheng-fang.github.io/2020-04-19-review_lenet/#2">[2]</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bZsmOjaScg2o155SU90ORQ.png" /><figcaption>Image 1: Visualization of CNN layers<br>Typical-looking filters on the first CONV layer (left), and the 2nd CONV layer (right) of a trained AlexNet. (From <a href="https://cs231n.github.io/understanding-cnn/">https://cs231n.github.io/understanding-cnn/</a>)</figcaption></figure><p>In the traditional solution, we often feed the machine learning model with the hand-design the features, as <em>SIFT</em>, <em>HOG</em>, <em>etc.</em> With globally trainable system, we can let the data tell us which are the most important features for a certain task.</p><h3>2. Design the CNN with knowledge</h3><p>In order to get self-learned features from neural network, we have to design a good architecture for the neural network. Yann LuCun indicated in his paper that <em>no learning technique can succeed without a minimal amount of prior knowledge about the task. …. a good way to incorporate with knowledge is to tailor its architecture to the task.</em> Now let’s focus on how to incorporate with knowledge when designing an architecture of <em>CNN</em>.</p><p>In 1962, Hubel and Wiesel[3] revealed that locally-sensitive, orientation-selective neuron in the cat’s visual systems. With the constrains of local connections, the neuron can learn some basic visual features, which could be reused or grouped to form new features in the following neuron. A convolution kernel can perfectly realize this constrains of receptive field.</p><p>Until here, we find a good tool, convolution kernel, to simulate the locally-sensitive, orientation-selective neuron. Then how can we overcome some common difficulties of image classification: shift, scale and distortion invariance.</p><p>Let’s first check how human being realize image classification. We maybe act like this:</p><ol><li>Scan the image with some visual pattern to find some features</li><li>Find the relation between features</li><li>Search the pattern of relation in the pattern database in our brain</li><li>Find the most similar one</li></ol><p>To realize the step 1, we can fix the weights of convolution kernel for the same feature map and generate several feature maps.</p><p>To realize the step 2, we consider the exact position of the feature are less important than the relative position of the feature to other features. So we can progressively reduce the spatial resolution (Sub-sampling). However, we lose information when reducing the image resolution. That’s why we need to increase the number of feature maps to keep the useful information as much as possible.</p><p>With all these knowledge, we have the general principle to design a CNN.</p><ol><li>Use convolution kernel</li><li>Shared weights</li><li>Sub-sampling and increasing the number of feature maps</li></ol><h3>3. Architecture of LeNet</h3><h3>3–1. LeNet-5</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PXworfAP2IombUzBsDMg7Q.png" /><figcaption>Image 2: Architecture of LeNet-5 (From <a href="http://vision.stanford.edu/cs598_spring07/papers/Lecun98.pdf">http://vision.stanford.edu/cs598_spring07/papers/Lecun98.pdf</a>)</figcaption></figure><p>Image 2[1]shows the architecture of <em>LeNet-5</em>.</p><h3>3–2. Boosted LeNet-4</h3><p><em>LeNet-4</em> is a simplified <em>LeNet-5</em>. It contains 4 first-level feature maps, followed by 16 sub-sampling map. We consider <em>LeNet-4</em> is a weaker classifier compared to <em>LeNet-5</em>. Yann LuCun applied the boosting technique to <em>LeNet-4</em>, marked boosted <em>LeNet-4</em>. The boosting method reaches better performance than <em>LeNet-5</em> of accuracy.</p><h3>4. Other interesting points</h3><p>In the domain of research of machine learning, we always mention the three key aspects to develop new methods. Yann LuCun also mentioned these in his paper:</p><ol><li>Machine with high capacity of computation is in low cost</li><li>Large database is available</li><li>Powerful machine learning techniques are available</li></ol><p>We should also consider these factors in our own products.</p><h3>5. Conclusion</h3><p>In this post, I shared my understanding of how to design a neural network. I believe it’s helpful in the practice of implementing and modifying a <em>CNN.</em></p><p>To sum up:</p><ol><li>Check the computational capacity, available database, technical support before start a machine learning project.</li><li>Once the project starts, try to get the prior knowledge about the project as much as possible.</li><li>Use this knowledge to design your own network.</li></ol><h3>Reference</h3><p>[1] LeCun, Yann and Bottou, Léon and Bengio, Yoshua and Haffner, Patrick <em>Gradient-Based Learning Applied to Document Recognition</em> IEEE, 1998</p><p>[2] <a href="https://cs231n.github.io/understanding-cnn/">Understanding and Visualizing Convolutional Neural Networks</a></p><p>[3] D. H. Hubel, T. N. Wiesel Receptive fields, binocular interaction and functional architecture in the cat’s visual cortex The Journal of Physiology, 1962</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ee92ff760ac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/review-of-lenet-5-how-to-design-the-architecture-of-cnn-8ee92ff760ac">Review of LeNet-5: How to design the architecture of CNN</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Overview of optimizers for DNN: when and how to choose which optimizer — Part 2]]></title>
            <link>https://medium.com/analytics-vidhya/overview-of-optimizers-for-dnn-when-and-how-to-choose-which-optimizer-part-2-16524dedbfd2?source=rss-e19717fcc1a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/16524dedbfd2</guid>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Sheng Fang]]></dc:creator>
            <pubDate>Mon, 13 Apr 2020 19:23:51 GMT</pubDate>
            <atom:updated>2020-04-17T18:06:29.584Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview of optimizers for DNN: when and how to choose which optimizer — Part 2</h3><p>In this story, I would like to <strong>review the development of optimization methods</strong> for deep neural network (<em>DNN</em>) and <strong>share suggestions to use optimizers</strong>.</p><blockquote>This is the Part 2 of my story. If you are not familiar with the optimizers of <em>DNN, </em>please read <a href="https://medium.com/@shengfang/overview-of-optimizers-for-dnn-when-and-how-to-choose-which-optimizer-951084b72061">Part 1</a>.</blockquote><p><strong>What you can find in Part 1 and Part 2:</strong></p><ol><li>A brief review of the popular optimizers from the an intuitive perspective. (Part 1)</li><li>The disadavantage of the popular adaptive optimizer, <em>Adam</em>. (Part 2)</li><li>Suggestions on jointly using different optimizers to achieve better performance. (Part 2)</li></ol><p><strong>Who may be interested:</strong></p><ol><li>Want a brief overview of optimizers from <em>SGD</em> to <em>Nadam</em>. (Part 1)</li><li>Want practices on how to use them. (Part 2)</li></ol><p>Adam is powerful to adjust the learning rate automatically. But why many researchers use <em>SGD</em> in their paper? What’s wrong with <em>Adam</em>? How to use the advantage of both <em>Adam</em> and <em>SGD?</em></p><p>We firstly review the disadvantage of Adam, then talk about the practices on jointly using <em>Adam</em> and <em>SGD</em>.</p><h3>What’s wrong with Adam?</h3><blockquote><strong>Problem 1: unconvergence</strong></blockquote><p>Paper [5] proves <em>Adam</em> could cause the unconvergence of the model in some case. Let’s check the details of the convergence when using different optimizers.</p><p>In the method of <em>SGD</em> with first order momentum, the learning rate is fixed. When the model is converging, the update value becomes close to 0.</p><p>For <em>AdaDelta/RMSProp</em> and <em>Adam</em>, the fluctuation of second order momentum can cause the unstable of the model. So the paper proposes to filter the second order momentum as follow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*HIjFyBiIE9LXSMZXoDj9tQ.png" /></figure><p>In this case, the update value shows a general decreasing tendency.</p><blockquote><strong>Problem 2: Local minimum</strong></blockquote><p>In the paper[6], the authors did experiments on <em>CIFAR-10</em> database. Adam converges quicker than <em>SGD</em>, but the <em>SGD</em> has a better performance. Their conclusion is: The update value of <em>Adam</em> is too small to converge to global minimun at the end of training.</p><h3>Adam or SGD?</h3><p><em>Adam</em> and <em>SGD</em>, which one is better? It’s hard to say.</p><p>For the new practitioner, it’s better to use <em>Adam</em>, which gives a good performance. <em>Adam</em> has an adaptive learning rate and is good at learning the representation of sparse data.</p><p>Although the convergence speed of <em>Adam </em>is high at the beginning of training, the experts prefer to use <em>SGD</em> or combine <em>Adam</em> and <em>SGD</em> because <em>Adam</em> may cause the model to be unstable or to converge to local minimum at the end of training . The authors of paper[6] recommend to use Adam at first for the quick convergence and use SGD to fine tune the model.</p><p>How can we combine <em>Adam</em> and <em>SGD</em>? Let’s focus on the following 2 questions:</p><ol><li>When to switch from <em>Adam</em> to <em>SGD</em>?</li><li>What learning rate should we use for <em>SGD </em>when switching from<em> Adam</em>?</li></ol><p>Let’s first answer the second question. We recall the update value for SGD and Adam:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*fGRfI7IUAMKQ12kc4sYhhA.png" /></figure><p>We would like the <em>SGD</em> can at least update the parameters as <em>Adam</em> does. For this purpose, we project the Update Value of <em>SGD</em> (<em>UV_SGD</em>) to the direction of the update value of <em>Adam (UV_ADAM)</em>. We have to ensure the projection of <em>UV_SGD</em> on the direction of <em>UV_ADAM</em> has the same value as <em>UV_ADAM</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*xo5NS3SJmpUNNalno2TIoQ.png" /></figure><p>According to this equation, we can calculate learning rate <em>α</em> of <em>SGD</em>. The authors add exponential average filter to the learning rate for a more stable value, marked as <em>ƛ</em>.</p><p>With the help of <em>α</em> and <em>ƛ</em>, let’s answer the first question: when to switch from <em>Adam</em> to <em>SGD</em>. As the authors mention in the paper, when the absolute difference between <em>α</em> and <em>ƛ</em> is smaller than a threshold. It’s time to switch.</p><h3>Reference:</h3><ol><li>S. Ruder, An Overview of Gradient Descent Optimization Algorithm, <a href="https://ruder.io/optimizing-gradient-descent/index.html">https://ruder.io/optimizing-gradient-descent/index.html</a></li><li>G. Hinton, N.Sricastava, K. Swersky, Nerual Networks for Machine Learning, <a href="http://www.cs.toronto.edu/~tijmen/csc321/slides/lecture_slides_lec6.pdf">http://www.cs.toronto.edu/~tijmen/csc321/slides/lecture_slides_lec6.pdf</a></li><li><a href="https://cs231n.github.io/neural-networks-3/#sgd">https://cs231n.github.io/neural-networks-3/#sgd</a></li><li><a href="https://zhuanlan.zhihu.com/p/32230623">https://zhuanlan.zhihu.com/p/32230623</a></li><li>Sashank J. Reddi, Satyen Kale, Sanjiv Kumar, On the Convergence of Adam and Beyond, <a href="https://openreview.net/forum?id=ryQu7f-RZ">https://openreview.net/forum?id=ryQu7f-RZ</a></li><li>Nitish Shirish Keskar, Richard Socher, Improving Generalization Performance by Switching from Adam to SGD, <a href="https://arxiv.org/abs/1712.07628">https://arxiv.org/abs/1712.07628</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16524dedbfd2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/overview-of-optimizers-for-dnn-when-and-how-to-choose-which-optimizer-part-2-16524dedbfd2">Overview of optimizers for DNN: when and how to choose which optimizer — Part 2</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Overview of optimizers for DNN: when and how to choose which optimizer — Part 1]]></title>
            <link>https://medium.com/analytics-vidhya/overview-of-optimizers-for-dnn-when-and-how-to-choose-which-optimizer-951084b72061?source=rss-e19717fcc1a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/951084b72061</guid>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[data-scientist]]></category>
            <dc:creator><![CDATA[Sheng Fang]]></dc:creator>
            <pubDate>Fri, 10 Apr 2020 12:37:13 GMT</pubDate>
            <atom:updated>2020-04-19T17:31:45.305Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview of optimizers for DNN: when and how to choose which optimizer — Part 1</h3><p>In this story, I would like to <strong>review the development of optimization methods</strong> for deep neural network (<em>DNN</em>) and <strong>share suggestions to use optimizers</strong>.</p><blockquote>This is the Part 1 of my story. If you are familiar with all the optimizers and want practices of using optimizers, please check the <a href="https://medium.com/@shengfang/overview-of-optimizers-for-dnn-when-and-how-to-choose-which-optimizer-part-2-16524dedbfd2">Part 2</a>.</blockquote><p><strong>What you can find in Part 1 and Part 2:</strong></p><ol><li>A brief review of the popular optimizers from the an intuitive perspective. (Part 1)</li><li>The disadavantage of the popular adaptive optimizer, <em>Adam</em>. (Part 2)</li><li>Suggestions on jointly using different optimizers to achieve better performance. (Part 2)</li></ol><p><strong>Who may be interested:</strong></p><ol><li>Want a brief overview of optimizers from <em>SGD</em> to <em>Nadam</em>. (Part 1)</li><li>Want practices on how to use them. (Part 2)</li></ol><h3>Intuitive perspective of optimization</h3><p>The goal of the optimization of <em>DNN</em> is to find the best parameters w to minimize the loss function <em>f(w, x, y)</em>, using <em>f(w)</em> bellow for simplification, subject to<em> x, y</em>, where <em>x</em> are the data and <em>y</em> are the labels. The gradient descent (<em>GD</em>) is the most frequently used optimization method for machine learning. In this method, we need another parameter called learning rate, <em>α</em>.</p><p>Now we start the process of gradient descent, at each batch/step <em>t:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*gRWsicLDp8_HSnWaW2krhw.png" /></figure><p>Next, let’s use these 4 steps to review different optimizers.</p><h3>Review of optimizers</h3><blockquote>Batch gradient descent (BGD)</blockquote><p><em>BGD</em> calculates the gradients with entire training dataset for only one update of parameters. It can be very slow to converge. If the training dataset is too large to fill into the memory, <em>BGD</em> becomes intractable. Moreover, <em>BGD</em> is not compatible to update a model online, for example, with new data on-the-fly.</p><blockquote>Stochastic gradient descent (<em>SGD</em>)</blockquote><p><em>SGD</em> calculates the gradients with one data. The calculation becomes faster, but the process of gradient descent becomes fluctuating. The direction of gradient descent calculated from only one data is not globally stable. It can be even opposite to the real gradient descent direction.</p><blockquote>Mini-batch gradient descent</blockquote><p>The trade-off between <em>SGD</em> and <em>BGD</em> is mini-batch gradient descent. This optimizer uses part of the data (<em>n &gt; 1</em>) to calculate the gradients and update the parameters<em> w</em>. This is the most popular setup used in modern machine learning training process. In the rest of this story, <em>SGD</em> means <em>SGD on mini-batch.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*eDDjx7qJHxoctQeURLcbcw.png" /></figure><blockquote>SGD with momentum</blockquote><p><strong>Motivation</strong>: <em>SGD</em> has trouble in optimizing in ravine-like surface curves. It is easily blocked in the saddle point. Image 1[1] shows behaviors of different optimizers on a ravine-like curves at a saddle point. The final position of red point is called saddle point. Don’t worry about the new names in the image, I will introduce them in the rest of the story.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*QBY1jeAWGhsiMkEbkDXmBw.gif" /><figcaption>Image 1: Saddle point</figcaption></figure><p>Image 2 and 3 [1] are the contour maps with local minimum in the middle. The lines with flash are the traces of optimization. For Image 2, it’s easy to find that the vertical step is big and horizontal step is small. But what we need is a big step along the horizontal direction and a small step along the vertical direction, which is depicted in the Image 3. The technique applied in Image 3 is call momentum, which accumulates the past gradients to determine current one to accelerate the convergence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*-iZ-UpsUJVOvtnUl1UIqxw.png" /></figure><p><strong>Solution</strong>: The implementation of <em>SGD with momentum</em> uses the method named exponential average. The exponential rate, <em>β</em>, is usually set to 0.9.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*qgKMa-kLqG7136fFlMIFow.png" /></figure><blockquote>SGD with Nesterov acceleration (Nesterov Accelerated Gradient, NAG)</blockquote><p><strong>Motivation</strong>: There are hundreds of thousands of parameters for a deep learning model. When we optimize the parameters in such a high dimension space, it’s easy to fall into a local minimum. If we can give the optimizer the ability to lookahead, it gives us more chance to step out the local minimum. <em>SGD with Nesterov acceleration </em>calculates the current gradients with a predicted approximation of <em>w</em>. The approximation is made by adding current <em>w</em> by the previous update value. Then the current update value is considered as a correction of the approximation. More explanations can be found in [2] and [3].</p><p><strong>Solution:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*zJHm09TMgB9Hn1oyUThgPA.png" /></figure><blockquote>AdaGrad</blockquote><p><strong>Motivation</strong>: The momentum give <em>SGD</em> the ability to adapt the update value according to the history of gradients. But the learning rate is the same for all parameters of <em>w</em>. Can we update the parameters with different learning rates depending on their importance? During the training of network, we can update slowly for those parameters associated with frequent features and update quickly for those parameters associated with infrequent features. So all the parameters can converge in similar rhythm. We use second order momentum to realize this proposition. We sum up the square of all past gradients of one parameter. The importance of this parameter is measured as dividing the general learning rate by the sum.</p><p>Solution:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*dmytdUhkVT5OPhdY7Tfgxw.png" /></figure><blockquote>AdaDelta/RMSprop</blockquote><p><strong>Motivation</strong>: The second order momentum calculated in <em>AdaGrad</em> is the accumulation of all the history, which becomes extremely big when the training process is long. This causes the update value infinitely close to 0 and the model can’t converge. In order to overcome this problem, we calculate exponential average of the second order momentum to replace the total accumulation of all past gradients.</p><p><strong>Solution:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*scm9ot8eEZjEYqXBz3cCtA.png" /></figure><blockquote>Adam</blockquote><p><strong>Motivation</strong>: <em>Adam</em> is the most frequently used optimizer, since it combines the <em>SGD with momentum</em> and <em>RMSProp</em>.</p><p><strong>Solution:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*RX7u9a-X3ZuCoyfx3sL6tw.png" /></figure><blockquote>Nadam</blockquote><p><strong>Motivation</strong>: Does <em>Adam</em> combine all the methods talked before? It seems we forget <em>Nesterov Accelerated Gradient</em>. Let’s integrate it and this optimizer is called Nadam.</p><p><strong>Solution</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*U0Tskv7N_hrbLMPQ2JwECw.png" /></figure><p>Now, we have reviewed most of the optimizers for <em>DNN</em> with an intuitive perspective. Some practitioners consider the optimizers like <em>Adam</em>, <em>SGD with momentum</em>, <em>etc</em>. are the <em>SGD</em> with learning rate scheduler. My opinion is Yes and No. Scheduled learning rate can have the same effect as <em>SGD with momentum</em>, but it can’t update parameters with different learning rates.</p><p>For new practitioners, it’s recommended to use <em>Adam</em>. But why more and more researchers use <em>SGD with momentum</em> and with scheduled learning rate in their paper? What’s wrong with <em>Adam</em>? How can we use <em>SGD with momentum</em> to achieve better performance? Please check the Part 2 of this story.</p><h4><strong>Reference</strong>:</h4><ol><li>S. Ruder, An Overview of Gradient Descent Optimization Algorithm, <a href="https://ruder.io/optimizing-gradient-descent/index.html">https://ruder.io/optimizing-gradient-descent/index.html</a></li><li>G. Hinton, N.Sricastava, K. Swersky, Nerual Networks for Machine Learning, <a href="http://www.cs.toronto.edu/~tijmen/csc321/slides/lecture_slides_lec6.pdf">http://www.cs.toronto.edu/~tijmen/csc321/slides/lecture_slides_lec6.pdf</a></li><li><a href="https://cs231n.github.io/neural-networks-3/#sgd">https://cs231n.github.io/neural-networks-3/#sgd</a></li><li><a href="https://zhuanlan.zhihu.com/p/32230623">https://zhuanlan.zhihu.com/p/32230623</a></li><li>Sashank J. Reddi, Satyen Kale, Sanjiv Kumar, On the Convergence of Adam and Beyond, <a href="https://openreview.net/forum?id=ryQu7f-RZ">https://openreview.net/forum?id=ryQu7f-RZ</a></li><li>Nitish Shirish Keskar, Richard Socher, Improving Generalization Performance by Switching from Adam to SGD, <a href="https://arxiv.org/abs/1712.07628">https://arxiv.org/abs/1712.07628</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=951084b72061" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/overview-of-optimizers-for-dnn-when-and-how-to-choose-which-optimizer-951084b72061">Overview of optimizers for DNN: when and how to choose which optimizer — Part 1</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hyper-parameters tuning practices: learning rate, batch size, momentum, and weight decay.]]></title>
            <link>https://medium.com/analytics-vidhya/hyper-parameters-tuning-practices-learning-rate-batch-size-momentum-and-weight-decay-4b30f3c19ae8?source=rss-e19717fcc1a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b30f3c19ae8</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[hyperparameter-tuning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[optimization]]></category>
            <dc:creator><![CDATA[Sheng Fang]]></dc:creator>
            <pubDate>Wed, 01 Apr 2020 10:35:19 GMT</pubDate>
            <atom:updated>2020-04-22T17:11:59.878Z</atom:updated>
            <content:encoded><![CDATA[<p>A review of the <a href="https://arxiv.org/abs/1803.09820">technical report</a>[1] by Leslie N. Smith.</p><p>Tuning the hyper-parameters of a deep learning (DL) model by grid search or random search is computationally expensive and time consuming. This technical report gives several practical suggestions and steps to choose the optimal hyper-parameters.</p><p>Some prior knowledge to fully understand this technical report:</p><ol><li>Overfitting/Underfitting</li><li>Learning Rate (LR)</li><li>Batch Size (BS)</li><li>Momentum</li><li>Weight Decay (WD)</li></ol><h3>Objective:</h3><p>Review the approach to tune the hyper-parameters that significantly reduce training time and improves performance.</p><h3>Where to find the clues to tune the hyper-parameters?</h3><p>The test/validation loss is a good indicator of the network’s convergence and should be examined for clues. In the report, the test/validation loss is used to provide insights on the training process and the final test accuracy is used for comparing performance.</p><h3>The effect of the hyper-parameters</h3><p>A well tuned machine learning model should be neither underfitting nor overfitting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*I16ywET-JG2tu8iGlMTryA.png" /><figcaption>From technical report [1]</figcaption></figure><p>When the model is under capacity, it can’t fit well the distribution of data. When the model is too complex, it can over fit the distribution of data and have low capacity in generalization.</p><p>In practice, we raise the complexity of model to fit the training data and use the regularization techniques to overcome the overfitting. Here is a table to summarize the effect of each hyper-parameter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7EPpFBm6gMZuhJbY5CEPow.png" /></figure><p><strong>Attention:</strong></p><p>The high level of the amount of regularization can help reduce the overfitting, but it could cause instability of model when passing the limitation. So we have to balance the amount of regularization.</p><p><strong>General principle: reducing other form of regularization and regularizing with large learning rates makes training significantly more efficient.</strong></p><h3>How to find a good set of hyper-parameters with a given dataset and architecture?</h3><ol><li>Learning rate (LR): Perform a learning rate range test to find the maximum learning rate.</li><li>Total batch size (TBS): A large batch size works well but the magnitude is typically constrained by the GPU memory.</li><li>Momentum: Short runs with momentum values of 0.99, 0.97, 0.95, and 0.9 will quickly show the best value for momentum.</li><li>Weight decay (WD): This requires a grid search to determine the proper magnitude.</li></ol><h3>Learning rate test</h3><p>In the LR range test, training starts with a small learning rate which is slowly increased linearly throughout a pre-training run. When starting with a small learning rate, the network begins to converge and, as the learning rate increases, it eventually becomes too large and causes the test/validation loss to increase and the accuracy to decrease. The learning rate at this extrema is the largest value.</p><p>There are several ways one can choose the minimum learning rate bound:</p><ol><li>a factor of 3 or 4 less than the maximum bound</li><li>a factor of 10 or 20 less than the maximum bound if only one cycle is used,</li><li>by a short test of hundreds of iterations with a few initial learning rates and pick the largest one that allows convergence to begin without signs of overfitting.</li></ol><h3>Grid search for weight decay</h3><p>When LR, BS, and Momentum are fixed, test 1e-3, 1e-4, 1e-5 and 0 as weight decay value and choose the best one.</p><h3>Conclusion</h3><p>This article summarizes:</p><ol><li>The effect of LR, BS, Momentum, and WD</li><li>The steps to choose the four hyper-parameters</li></ol><blockquote>If you wish to have more details and explanations with experiments, please read the technical report [1].</blockquote><p>Ref:</p><p>[1] A disciplined approach to neural network hyper-parameters: Part 1 — learning rate, batch size, momentum, and weight decay</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b30f3c19ae8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/hyper-parameters-tuning-practices-learning-rate-batch-size-momentum-and-weight-decay-4b30f3c19ae8">Hyper-parameters tuning practices: learning rate, batch size, momentum, and weight decay.</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>