<?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 Pranav Raikote on Medium]]></title>
        <description><![CDATA[Stories by Pranav Raikote on Medium]]></description>
        <link>https://medium.com/@pranavraikote?source=rss-8143530c6291------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nl2W-RfLIB8QVh30ICDCag@2x.jpeg</url>
            <title>Stories by Pranav Raikote on Medium</title>
            <link>https://medium.com/@pranavraikote?source=rss-8143530c6291------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 15:09:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pranavraikote/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[WaveNILM: A Causal Neural Network for Power Disaggregation]]></title>
            <link>https://medium.com/data-science/wavenilm-a-causal-neural-network-for-power-disaggregation-15e0024ff7c5?source=rss-8143530c6291------2</link>
            <guid isPermaLink="false">https://medium.com/p/15e0024ff7c5</guid>
            <category><![CDATA[nilm]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[wavenet]]></category>
            <category><![CDATA[convolutional-network]]></category>
            <category><![CDATA[energy-disaggregation]]></category>
            <dc:creator><![CDATA[Pranav Raikote]]></dc:creator>
            <pubDate>Mon, 19 Dec 2022 20:50:16 GMT</pubDate>
            <atom:updated>2022-12-19T20:50:16.905Z</atom:updated>
            <content:encoded><![CDATA[<h4>Deep Learning in NILM</h4><h4>Causality deserves more attention in Deep Learning</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AlhLeoTIxAyDTFYXI9rEeQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@ale_s_bianchi?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Alessandro Bianchi</a> on <a href="https://unsplash.com/s/photos/Energy-industry?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h4>Introduction</h4><p>Power Disaggregation is one of the important processes involved in building better grid infrastructures for the ever-increasing demand for energy consumption. Disaggregation means “<em>to separate individual appliances’ consumption values</em>” from the aggregate total power consumption. As we all know, Deep Neural Networks are being applied to solve complex problems in almost all industries and verticals, and it has made its mark in the Energy industry too. We have seen the usage of LSTMs [1], 1D-CNNs, Transformers [2], and other Time-series based algorithms applied for popular use-cases like Load Forecasting, Integration Strategies [3], Demand Response [4, 5], NILM (Non-Intrusive Load Monitoring), P2P Trading, etc. We are focusing on NILM in this article, which stands out as one of the important processes in developing Smart Grid infrastructure for the future.</p><h4>Background</h4><p>NILM is quite a seasoned research area, being first proposed in 1992. Fast forward 2 decades and we have a lot of exciting research [6, 7, 8] in this field with Deep Learning taking the majority spotlight among the various other ways of approaching and solving this problem. This domain involves time-series data and directly implicates the use of sequence modeling architectures like RNNs, LSTMs, GRUs, and of course the most latest Transformers. However, these are all non-causal and require future values for disaggregation at the current time step <em>t</em>.</p><p>TCNs (Temporal Convolutional Networks) came into existence and challenged the LSTMs and GRUs in various sequence modeling tasks with longer effective memory in addition to being causal. The hidden layers in a TCN are of the same size as the input layer with zero padding to ensure the sequence length stays the same throughout. Also, the way it prevents information leakage from the future to the past is by using causal convolution layers that convolve over <em>t-n</em> time steps at current time step <em>t</em>. Dilated convolutions with various dilation factors are employed to look back very far (exponentially large receptive field) in the past for factoring in the predictions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*KT2pR41UgFgP06orqwBFEQ.png" /><figcaption>Standard Convolution vs Dilated Convolution for Temporal Data. Image Credits — WaveNILM <a href="https://arxiv.org/pdf/1902.08736.pdf">paper</a></figcaption></figure><h4>Idea &amp; Architecture</h4><p>WaveNILM [9] builds on top of Causal CNN [10] architecture with a few improvements in the process of building a better and more efficient architecture for real-time disaggregation, much needed in the age of Smart and Dynamic grids.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vNb1963PhxUWtj8wEzemjQ.png" /><figcaption>This is how a block looks like in the WaveNILM architecture. Image Credits — WaveNILM <a href="https://arxiv.org/pdf/1902.08736.pdf">paper</a></figcaption></figure><p>The above illustration depicts how the WaveNILM uses a Gated Dilation method — Output from the Conv-Dense layers is split into two directions, namely the Sigmoid (Gate) path, and the ReLU (Regressor) path. The outputs are then concatenated, which forms the overall output for a block. There are several blocks stacked in a residual manner, but the nature of the residual connection is slightly different — The Skip connection from each block doesn’t skip just 1 block, instead skips several blocks and joins the network at the final few downstream layers.</p><p>The input layer is a 512 unit Time-distributed layer followed by a stack of gated blocks. Here, all the skip connections are collected and concatenated to form another new layer that acts as an output mask. The output mask is multiplied with that unit corresponding to the appliance we want to disaggregate due to the multiple input nature of the architecture.</p><h4>Results &amp; Benchmarks</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*Y-1yQYplCXl_PzRcCPKj8Q.png" /><figcaption>Single vs Multiple input experiments. Image Credits — WaveNILM <a href="https://arxiv.org/pdf/1902.08736.pdf">paper</a></figcaption></figure><p>Let’s quickly discuss Deferrable load, one of the important load signature types to be disaggregated for key benefits. Deferrable Loads are large loads that can be run at off-peak hours. Examples are HVAC, heat pumps, dryers, ovens, and dishwashers. Successful disaggregation of the above loads can be instrumental in preventing blackouts and load sheddings across the grid.</p><p>Data from AMPds2 [11] was first scaled between <em>[0, 1]</em>, batched, and trained for around 500 epochs on a 1-day (1440) sample set. Since WaveNILM is a regressor network, we have to focus on the error rate rather than the categorical output. The Estimated Accuracy illustrated below is one of the widely adopted metrics for these scenarios,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*Lmz7Na0rwOlstPweQyGtAA.png" /><figcaption>Image by Author</figcaption></figure><p>where s<em>k</em>^(t) is the predicted power of an appliance at time <em>t</em>, s<em>k</em>(t) the ground truth, T and K are the total time and number of appliances respectively. WaveNILM was studied with various input signals like Current (I), Power (P), Reactive Power (Q), and Apparent Power (S). When choosing multiple input signals, either P or I was selected as output signals.</p><p>Coming to comparison, WaveNILM has been benchmarked against SSHMM [12] architecture for noisy and denoised input signals. The below tables show the performance of WaveNILM vs SSHMM for single and multiple inputs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*Eu91lvUGyjj7-GKxqc2rdA.png" /><figcaption>Denoised results on deferrable loads. Image Credits — WaveNILM <a href="https://arxiv.org/pdf/1902.08736.pdf">paper</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*M4jPkiI-oVn7EXjpIJ7h5w.png" /><figcaption>Noisy case results on deferrable loads. Image Credits — WaveNILM <a href="https://arxiv.org/pdf/1902.08736.pdf">paper</a></figcaption></figure><h4>My Thoughts</h4><p>In my opinion, WaveNILM is a good approach, in general to move towards causality-based neural networks. Causality is one step ahead of correlation in understanding the model behavior when things change from its basic assumptions on the data. Deep Learning with causation is the need of the hour for better modeling and robustness. Knowing the cause-effect aspect can make AI applications explainable and smarter.</p><p>One more aspect is the dataset, only a single dataset was inspected and used. I was expecting the usage of popular datasets like REDD and Pecan Street. Usage of these datasets would have opened up the competition in benchmarks and presented more realistic numbers of performance.</p><h4>Conclusion</h4><p>WaveNILM presented a simple and effective causal network for solving the real-time disaggregation problem. Its main advantage is the ability to add/remove the number of inputs for disaggregation for a better model fit. There was also a focus on the types of Power involved, and how going forward infrastructure to safely capture these readings will go a long way in developing AI systems for the consumer and the grid operator.</p><h4>References</h4><p>[1] Parallel LSTM Architectures for Non-Intrusive Load Monitoring in Smart Homes: <a href="https://ieeexplore.ieee.org/document/9308592">https://ieeexplore.ieee.org/document/9308592</a></p><p>[2] ELECTRIcity: An Efficient Transformer for Non-Intrusive Load Monitoring: <a href="https://pubmed.ncbi.nlm.nih.gov/35458907/">https://pubmed.ncbi.nlm.nih.gov/35458907/</a></p><p>[3] Non-intrusive Electric-vehicle Load DisaggregationAlgorithm for a Data-driven EV Integration Strategy: <a href="https://ieeexplore.ieee.org/document/9794150">https://ieeexplore.ieee.org/document/9794150</a></p><p>[4] Deep Learning for Intelligent Demand Response and Smart Grids: A Comprehensive Survey: <a href="https://arxiv.org/pdf/2101.08013.pdf">https://arxiv.org/pdf/2101.08013.pdf</a></p><p>[5] Prediction of Electric Energy Consumption for Demand Response using Deep Learning: <a href="https://ieeexplore.ieee.org/document/9862353">https://ieeexplore.ieee.org/document/9862353</a></p><p>[6] Analyzing Load Profiles of Energy Consumption toInfer Household Characteristics Using Smart Meters: <a href="https://www.mdpi.com/1996-1073/12/5/773">https://www.mdpi.com/1996-1073/12/5/773</a></p><p>[7] Low-Frequency Non-Intrusive Load Monitoring of Electric Vehicles in Houses with Solar Generation: Generalisability and Transferability: <a href="https://www.mdpi.com/1996-1073/15/6/2200">https://www.mdpi.com/1996-1073/15/6/2200</a></p><p>[8] Sequence-to-point learning with neural networks for non-intrusive load monitoring: <a href="https://arxiv.org/pdf/1612.09106.pdf">https://arxiv.org/pdf/1612.09106.pdf</a></p><p>[9] WaveNet: A Generative Model for Raw Audio: <a href="https://arxiv.org/pdf/1609.03499v2.pdf">https://arxiv.org/pdf/1609.03499v2.pdf</a></p><p>[10] WaveNILM: <a href="https://arxiv.org/pdf/1902.08736.pdf">https://arxiv.org/pdf/1902.08736.pdf</a></p><p>[11] AMPds2 dataset: <a href="https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/FIE0S4">https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/FIE0S4</a></p><p>[12] Exploiting HMM Sparsity to Perform Online Real-Time Nonintrusive Load Monitoring: <a href="https://ieeexplore.ieee.org/document/7317784">https://ieeexplore.ieee.org/document/7317784</a></p><p>[13] WaveNILM implementation: <a href="https://github.com/picagrad/WaveNILM">https://github.com/picagrad/WaveNILM</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15e0024ff7c5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/wavenilm-a-causal-neural-network-for-power-disaggregation-15e0024ff7c5">WaveNILM: A Causal Neural Network for Power Disaggregation</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[Sequence-to-Point Neural Network for NILM]]></title>
            <link>https://medium.com/data-science/sequence-to-point-neural-network-for-nilm-6719584fa21f?source=rss-8143530c6291------2</link>
            <guid isPermaLink="false">https://medium.com/p/6719584fa21f</guid>
            <category><![CDATA[energy]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[nilm]]></category>
            <category><![CDATA[sequence-to-sequence]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Pranav Raikote]]></dc:creator>
            <pubDate>Fri, 09 Dec 2022 14:59:35 GMT</pubDate>
            <atom:updated>2022-12-09T14:59:35.924Z</atom:updated>
            <content:encoded><![CDATA[<h4>Deep Learning in NILM</h4><h4>A CNN for Sequence modelling? Let’s see how it fares</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qidEh7dbb5U1S2i29Wt0ag.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@pavement_special?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Riccardo Annandale</a> on <a href="https://unsplash.com/s/photos/energy?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h4>Introduction</h4><p>NILM (non-intrusive load monitoring) has been one of the important processes in understanding customer behavior and building scalable infrastructure solutions. The most basic use case of NILM is to provide the end-user a better understanding of their own household’s energy consumption. This in turn helps users develop better consumption habits, which results in a 5–10% reduction in consumption. So far, we have seen many Deep Learning methods including HMMs, RNNs, LSTMs, GRUs, and Transformers under the domain of Sequence Modelling that predominantly depends upon moving sliding windows to capture patterns for a disaggregation result.</p><h4>Key Applications of NILM</h4><ol><li>Identifying energy-saving opportunities: By providing detailed information about the electrical consumption of individual appliances, NILM can help to identify opportunities for reducing energy usage. For example, if a particular appliance is using more energy than expected, it may be possible to switch to a more energy-efficient model or to use the appliance less frequently</li><li>Supporting demand-side management: NILM can be used to support demand-side management, which involves controlling the demand for electricity in order to improve the efficiency of the power grid. By providing real-time information about the electrical consumption of individual appliances, NILM can help utilities to better manage demand and avoid overloading the grid</li><li>Enhancing energy audits: Energy audits are used to assess the energy efficiency of a building or other facility. By incorporating NILM data, energy audits can provide a more detailed and accurate analysis of energy usage, which can help to identify specific areas where improvements can be made.</li></ol><h4>Background</h4><p>One of the popular Sequence Modelling architectures Seq2Seq [1] is dominating the majority of the tasks in this domain. In a Seq2Seq-type architecture for NILM, the sliding window(s) of the input power sequence will learn to correspond to the sliding window(s) of the output power of the appliance. The problem here is threefold,</p><ol><li>The output window elements are computed many times as part of the sliding window process</li><li>A particular few sliding windows might approximate a better result</li><li>Computationally expensive</li></ol><p>Seq2Point [2] set out to solve the major bottlenecks by proposing outputting a single value (midpoint of the output window) from a sequence input window. Let’s do a deep dive and understand how Seq2Point architecture reduced by around 83% of the error rate from the previous work.</p><h4>Idea and Architecture</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tLbbmtp8IATXC29g.png" /><figcaption>The blueprint of Seq2Point architecture. Image Credits — Seq2Point <a href="https://arxiv.org/abs/1612.09106">paper</a></figcaption></figure><p>The idea for Seq2Point is that for an input window, the output will be the corresponding midpoint element of the target appliance window. However, there is an important underlying assumption: “Midpoint element is represented as a non-linear regression of the mains input window”. This assumption goes based on the midpoint element (output) of the appliance window and should factor in surrounding information, i.e. before and after the appliance activity.</p><p>For training it, the output sequence is padded with zeros at both ends to deal with the endpoints of a sequence. The key differentiator in Seq2Point is that there will be a single absolute output x(t), rather than a smoothed (averaged) prediction from a window.</p><h4>Results and Benchmarks</h4><p>UK-DALE [3] and REDD [4] were the datasets chosen for the training and Seq2Point was compared with Seq2Seq for benchmarking and analysis.</p><p>Data has to be prepared carefully in NILM-based neural networks. The input mains sequence was selected based on the sequence length (599 time stamps) and the output was the midpoint element in the target sequence. The values within the sequence windows were normalized.</p><p>Coming to the evaluation metrics, MAE (Mean Absolute Error) was used for calculating the error at every timestamp t, and Normalized SAE (Signal Absolute Error) for a total error in energy over a longer period.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZvfLCrzXz3xkXtkl.png" /><figcaption>Comparison of MAE and SAE error rates for various appliances. Image Credits — Seq2Point <a href="https://arxiv.org/abs/1612.09106">paper</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ql_LHBDF3nZp1j_j.png" /><figcaption>Similar comparison but focused on Seq2Point and Seq2Seq using methodologies from Seq2Point paper. Image Credits — Seq2Point <a href="https://arxiv.org/abs/1612.09106">paper</a></figcaption></figure><p>As we can see in the above tables, Seq2Point outperforms Seq2Seq and the AFHMM by a considerable margin on a majority of the selected appliance.</p><h4>My Thoughts</h4><p>When I was going through the feature maps and the ablation study performed for observing the understanding of how the network is learning the features, I was taken aback by how well the features were learned by the network. Convolutional Neural Networks has once again shown that it’s one of the best feature extractors/pattern finders out there. There are a few sets of filters that picked up amplitude changes and a few others focused on state changes. Surprisingly it was able to learn the duration of state changes for each appliance!</p><p>Head over to the Visualization of latent features section of the Seq2Point paper.</p><h4>Real-world examples of NILM</h4><p>The Open Energy Monitor is an open-source NILM system that is designed for use in both residential and commercial settings. It uses sensors to monitor the electrical consumption of individual appliances, and provides users with detailed information about their energy usage. This allows users to identify ways to reduce their energy consumption, and to monitor their progress over time.</p><p>The Energy Detective (TED) is a NILM system that is designed for residential use. It uses sensors to monitor the electrical consumption of individual appliances, and provides users with real-time information about their energy usage. This allows users to identify which appliances are using the most energy, and to take steps to reduce their energy consumption.</p><h4>Conclusion</h4><p>Seq2Point is a great addition to the NILM Research space by virtue of its simplified architecture that delivers big on results. The datasets used were real-world, hinting at a possible deployment in real-world scenarios and creating business value. It outperforms Seq2Seq (De-facto boss in sequence modelling) and also explains the features and behavior of the network.</p><p><strong><em>Bonus</em></strong>: Here is the implementation of Seq2Point in TensorFlow — <a href="https://github.com/MingjunZhong/seq2point-nilm">https://github.com/MingjunZhong/seq2point-nilm</a></p><h4>References</h4><p>[1] Seq2Seq: <a href="https://arxiv.org/abs/1409.3215">https://arxiv.org/abs/1409.3215</a></p><p>[2] Seq2Point: <a href="https://arxiv.org/pdf/1612.09106.pdf">https://arxiv.org/abs/1612.09106</a></p><p>[3] UK-DALE: <a href="https://jack-kelly.com/data/">https://jack-kelly.com/data/</a></p><p>[4] REDD: <a href="https://energy.duke.edu/content/reference-energy-disaggregation-data-set-redd">https://energy.duke.edu/content/reference-energy-disaggregation-data-set-redd</a></p><p><em>Originally published at </em><a href="https://blog.plexflo.com/sequence-to-point-neural-networks-for-nilm"><em>https://blog.plexflo.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6719584fa21f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/sequence-to-point-neural-network-for-nilm-6719584fa21f">Sequence-to-Point Neural Network for NILM</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[Quick guide on Deep Learning for Time-series Multi-Label Classification]]></title>
            <link>https://pranavraikote.medium.com/quick-guide-on-deep-learning-for-time-series-multi-label-classification-4ecba5ce5da7?source=rss-8143530c6291------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ecba5ce5da7</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[time-series-analysis]]></category>
            <dc:creator><![CDATA[Pranav Raikote]]></dc:creator>
            <pubDate>Mon, 07 Mar 2022 17:20:33 GMT</pubDate>
            <atom:updated>2022-03-07T17:20:33.290Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y77MkX5Ytwa2-XV0FCyGog.jpeg" /></figure><p>Working on time-series data is quite cumbersome, considering a variety of components in the data and the steps to be taken in preparing the data for training from the raw data dump. Moreover, employing Machine Learning or Deep Learning models on such a data form is quite tricky especially if you are new to this domain. In this article, I want to share my observations and a few tips on how to tackle some of the major problems in the multi-label classification of time-series data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/0*9LrOfGCJKJ0TaZ8l.png" /><figcaption>Illustration of ROC Curve. Image Credits — <a href="https://en.wikipedia.org/wiki/Receiver_operating_characteristic">ROC Wiki</a></figcaption></figure><p>In the recent few days, I was working on a multi-label classification problem involving time-series data and I encountered many new things (including a big red flag), wanted to share a few pointers so that anyone working on a similar problem statement can get a jump start.</p><p>Few TensorFlow references here and there, but overall it’s framework-agnostic😊</p><ol><li><em>Very important to understand the scale of values in your data, get that sorted out at the beginning itself</em></li><li><em>I used tf.data for loading, handling, and processing data from a CSV file and it is was very straightforward and easy-to-use function calls (can pipe multiple functionalities — added advantage)</em></li><li><em>I have seen many developers start big and slowly reduce the model complexity and I’m also guilty of doing this in the past. But, lesson learned — Start small and increase complexity if you feel the training is getting saturated after certain epochs. Having a smaller model (if performing on par with a bigger model) is always advantageous because of its latency when deployed</em></li><li><em>Always use a custom training loop or over-ride the model.fit() for having better control on training than using the highly abstract way of training a model</em></li><li><em>When it comes to multi-label classification, tracking or depending on just accuracy and loss is a big NO. Use precision, recall, f1-score as they are better indicators. This is the biggest red flag!</em></li><li><em>Write code snippets around these metrics and have rightly configured custom callbacks for an efficient training</em></li><li><em>Use the ROC and Precision-Recall curve to understand the outputs of your model given the fact you can set thresholds for the sigmoid output for setting a label of 1/0 for the neurons</em></li><li><em>Actively track your training runs using any of the open-source tools or using a code script. Better to use tools that can do the heavy lifting, and you can focus on data and model than other things (there are plenty of tools out there). In short, start adopting MLOps practices.</em></li><li><em>One final thing — Use docker and write the code in such a way that it enables you to stick your container in a Multi-GPU or TPU environment, and it still runs flawlessly for a scaled-up training exercise</em></li></ol><p>I will keep sharing my views and a few more tips as and when I progress through solving my problem statement. Until then, I hope the above tips will aid you when working on a similar problem statement.</p><p>‍</p><p>Stay up to date with the latest video business news, strategies, and insights sent straight to your inbox!</p><p><em>Originally published at </em><a href="https://www.plexflo.com/post/quick-guide-on-deep-learning-for-time-series-multi-label-classification"><em>https://www.plexflo.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ecba5ce5da7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PolyViT: Co-training Vision Transformers on Images, Videos and Audio]]></title>
            <link>https://medium.com/data-science/polyvit-co-training-vision-transformers-on-images-videos-and-audio-f5e81bee9491?source=rss-8143530c6291------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5e81bee9491</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[vision-transformer]]></category>
            <category><![CDATA[polyvit]]></category>
            <category><![CDATA[research-paper]]></category>
            <dc:creator><![CDATA[Pranav Raikote]]></dc:creator>
            <pubDate>Wed, 15 Dec 2021 13:37:51 GMT</pubDate>
            <atom:updated>2021-12-15T13:37:51.462Z</atom:updated>
            <content:encoded><![CDATA[<h4>Transformers in Deep Learning</h4><h4>Multi-Modality is the way forward for efficient and scalable solutions in the Transformer Era</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fVniO2FZsuP4wwfJXdpf5g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@halacious?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Hal Gatewood</a> on <a href="https://unsplash.com/s/photos/brain?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>The famed Transformer [1] architecture released in 2017 was simply outstanding and went on to break almost all SOTA benchmarks in Natural Language Processing. It was then adapted to other domains like Image &amp; Video classification, Object Detection, Audio classification, and even in Generative networks without any major modifications. One of the popularly known architecture — Vision Transformer [2] achieved SOTA results on the ImageNet Classification task which then set the base in the Computer Vision domain. We now have mainstream research happening around Transformers for every domain under the Deep Learning umbrella. The architectures and results achieved are exceptional but throw a simple question,</p><blockquote><em>Do we need a model for each modality?</em></blockquote><p>Can we train a single Transformer model for multiple datasets? <strong>PolyViT</strong> [3] is set to solve that by adopting a co-training method that can be used to train a single model on image, video, and audio datasets. This would be massive in terms of reducing the efforts over multiple modalities.</p><p><strong>Note:</strong> Modality can be viewed as “type of input processed”</p><h3>Background</h3><p>Multi-task learning is not new in Deep Learning. An abstract idea for Multi-task learning is to develop architectures that can generalize whilst share the parameters across multiple types of datasets like Image, Video, Speech, Point Clouds, etc. Important observation was the reduced performance when compared to a single-task model which in turn hindered more research in this particular hypothesis. And the performance further decreases when more tasks are combined which led to little or no encouragement for researchers to venture into this space further. To train a multi-task model is quite tricky too in terms of initializing and calibrating the parameters towards a stable training/fitting.</p><blockquote>Isn’t this also an attempt to mimic a human brain which can effortlessly learn patterns across various modalities?</blockquote><p>The Perceiver [4] architecture is a transformer that could process, tokenize and train different modalities using cross-attention processing of latent tokens. But this was not a parameter-shared network. We have architectures like UniT [5] and Joint Video and Image encoder [6] which are employing multi-modal strategies but do not outperform the single-task models.</p><h3>Idea &amp; Architecture</h3><p>To set the context for PolyViT, we first need to know about 3 Transformer architectures that are best in their respective dataset modality,</p><ol><li>Vision Transformer (ViT) for Image</li><li>VideoVision Transformer (ViViT)[7] for Video</li><li>Audio Spectrogram Transformer (AST)[8] for Audio</li></ol><p>Check out this <a href="https://amaarora.github.io/2021/01/18/ViT.html">blog</a> on ViT for a comprehensive understanding of the architecture. ViViT is an extension of ViT with the only notable difference being 3D patches (Spatio-temporal) called tubelets than the 2D image patches observed in ViT. The AST is simply a ViT trained on spectrogram (time-frequency representation of speech/audio) images. All three models achieve their best performance when pre-trained on datasets like ImageNet-21K or JFT.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*uXqoUlZA4rnKN7f0Yk1Q8g.jpeg" /><figcaption>PolyViT architecture illustrating the co-training setup. Image Credits — PolyViT <a href="https://arxiv.org/pdf/2111.12993.pdf">paper</a></figcaption></figure><p>Coming to PolyViT, we can see in the above image how the <em>encoder </em>is shared among the modalities. The base architecture is a pre-trained ViT with added task-specific tokenizers and attention heads. We have separate input and positional embeddings and the class tokens for each of the three modalities image, video (sequence of frames), and audio. The encoding process is modality-specific to make sure it caters to different number of tokens/modality. During training, it performs one task from one modality in each pass (Image classification task in Image modality).</p><h4>Co-training</h4><p>This procedure involves using the same set of hyperparameters for different tasks but with mini-batches sourced from the same modality. The optimization is handled by Stochastic Gradient Descent (SGD). There are various ways of constructing the mini-batches — Task-by-Task, Alternating, Accumulating gradients, Uniform sampling, and Weighted sampling. We use the terminology <em>U </em>which denotes the total number of SGD steps during co-training.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*xvwtAtZbYJokNPz9gO-AlA.jpeg" /><figcaption>Mini batch sampling methods. Image Credits — PolyViT <a href="https://arxiv.org/pdf/2111.12993.pdf">paper</a></figcaption></figure><p>As we can observe from the above methods, Task-by-task sampling follows an order wherein the SGD steps are applied for each task. The task order is random. Alternating sampling is (deterministic) repetitive with the SGD acting once per task. Uniform sampling involves constructing the batches from a uniform distribution with a probability of 1/T resulting in U/T steps per task. Weighted sampling is a schedule that has a certain weight assigned to each task according to its number of steps in a single-task model. Finally, the Accumulating gradients process is quite different from the rest — store the gradients after a single forward and back prop of each task and then apply the parameter for that entire batch (containing multiple tasks).</p><blockquote>The intuition I’m having is we should have a task and apply parameter updates for that only; Having all sorts of tasks and updates within a batch is going to screw up the training quite badly.</blockquote><p>Whichever sampling technique used, results in parameter sharing over the defined <em>n </em>tasks which is one of the primal objectives of PolyViT. To enable a large number of modalities, the authors introduced a special modality-specific layer, L(adapt) which is applied right after tokenization.</p><h3>Results &amp; Benchmarks</h3><p>Now we shall observe the results of PolyViT for each of the task-sampling methods for a variety of datasets like ImageNet-1K, CIFAR-10 &amp; 100, Kinetics400, Moments in Time (MIT), AudioSet, and VGGSound.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*CW-3KLPPcWgQJb4Z_JTjlA.jpeg" /><figcaption>PolyViT trained on various task sampling methods for a 9-task training. L(adapt) = 0 which means no modality-specific layers used. Image Credits — PolyViT <a href="https://arxiv.org/pdf/2111.12993.pdf">paper</a></figcaption></figure><p>The results reiterate the fact that the gradient updates should be task-specific for robust results and if are randomly sampled in Task-by-Task sampling it performs very poorly. The weighted schedule was found to be the best and hence used in all subsequent experiments. One thing to note here is that the number of steps per task is derived from its single task baseline which results in the same computational resources as 9-tasks trained separately. Fabulous isn’t it?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*8s-fSa-0AWVNISzkFMyiYA.jpeg" /><figcaption>PolyViT with varying L(adapt) values compared to single-task baselines. Image Credits — PolyViT <a href="https://arxiv.org/pdf/2111.12993.pdf">paper</a></figcaption></figure><p>After observing the above results, the PolyViT trained for a single modality (3 models with 263M) is outperforming the SOTA benchmark in 7 out of 9 tasks. Using co-training for all 9 tasks, it is within 0.2–0.3 percent from the SOTA results with a 3x decrease in parameters(93M). PolyViT with L(adapt) = 0 is almost within 1% of the single-task baselines with an 8x decrease in parameters (773M to 93M). Also, we can conclude that the single modality co-training is improving the accuracy on the smaller datasets within each modality, confirming the effect of regularization and ability to fit on smaller datasets which were not seen in standard ViT models.</p><p>Similarly, experiments were performed on trained PolyViT and evaluated on downstream tasks on a linear head. The multi-modal PolyViT shines here too with very good performance on 11 tasks. Further, buoyed by the improved performance within a modality, authors co-trained PolyViT’s for a single modality which resulted in surpassing the SOTA benchmarks with a considerable reduction in parameters. Kindly refer to the PolyViT paper for more details on the above-mentioned experiments and training-setup details (Appendix section).</p><h3>My Thoughts</h3><p>In my opinion, it is an excellent attempt that has delivered SOTA-level results. We have a lot of positives like parameter efficiency, single model as opposed to n task-specific models, simple to implement and maintain. The inference time is also constant throughout the modalities and tasks.</p><p>PolyViT will now enable the deployment of relatively light-weighted multi-modal transformer models on Edge devices as opposed to heavy and task-specific models. Think about the usability of a single model for many tasks on a device. The avenues can surely be expanded and scaled such that we can hopefully have a “One-Model for a majority of ML tasks”. Also, the fact of regularizing effect on smaller datasets is a welcome addition making it easier for individual practitioners/researchers to prevent the overfitting problem.</p><p>The only small caveat I observed is the opposition to the initial hypothesis of a fully parameter shared model with the addition of L(adapt) layers. Since, the results from the model with L(adapt) = 0 settings are very good, we can give this a pass and consider PolyViT as a fully parameter shared model 😊</p><h3>Conclusion</h3><p>PolyViT with co-training and single modality setup surpassed the previous SOTA results across 5 standard video and audio classification tasks. Change it to a multi-modal setting and it is efficient with very little drop in performance (0.5–1%). The fact that it can learn and generalize for multiple tasks, multiple modalities (domains) with near SOTA performance is itself a huge win. The second biggest thing would be the parameter efficiency observed in multi-modal setup when compared to their single-task baselines. And due to the robust representation, fine-tuning becomes easier without any hyperparameter tuning. There is still scope for experimentation in the form of using the larger datasets like the ImageNet-21K dataset and expanding to other domains.</p><h4>More research paper reviews by me</h4><ul><li><a href="https://towardsdatascience.com/non-deep-networks-b0b80c65c7c6">Non-Deep Networks</a></li><li><a href="https://towardsdatascience.com/expire-span-not-all-memories-are-created-equal-explained-ffcbd9663bfd">Expire-Span: Not All Memories are Created Equal explained</a></li><li><a href="https://towardsdatascience.com/mlp-mixer-an-all-mlp-architecture-for-vision-7438fac99a06">MLP-Mixer: An all-MLP Architecture for Vision</a></li></ul><h3>References</h3><p>[1] Transformer : <a href="https://arxiv.org/pdf/1706.03762.pdf">https://arxiv.org/pdf/1706.03762.pdf</a></p><p>[2] Vision Transformer: <a href="https://arxiv.org/pdf/2010.11929.pdf">https://arxiv.org/pdf/1409.1556.pdf</a></p><p>[3] PolyViT: <a href="https://arxiv.org/pdf/2111.12993.pdf">https://arxiv.org/pdf/2111.12993.pdf</a></p><p>[4] Perceiver: <a href="https://arxiv.org/pdf/2103.03206">https://arxiv.org/pdf/2103.03206</a></p><p>[5] UniT: <a href="https://arxiv.org/pdf/2102.10772.pdf">https://arxiv.org/pdf/2102.10772.pdf</a></p><p>[6] Joint Video and Image Encoder: <a href="https://arxiv.org/pdf/2104.00650.pdf">https://arxiv.org/pdf/2104.00650.pdf</a></p><p>[7] Video Vision Transformer: <a href="https://arxiv.org/pdf/2103.15691">https://arxiv.org/pdf/2103.15691</a></p><p>[8] Audio Spectrogram Transformer: <a href="https://arxiv.org/pdf/2104.01778">https://arxiv.org/pdf/2104.01778</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5e81bee9491" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/polyvit-co-training-vision-transformers-on-images-videos-and-audio-f5e81bee9491">PolyViT: Co-training Vision Transformers on Images, Videos and Audio</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[Non-Deep Networks]]></title>
            <link>https://medium.com/data-science/non-deep-networks-b0b80c65c7c6?source=rss-8143530c6291------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0b80c65c7c6</guid>
            <category><![CDATA[convolutional-network]]></category>
            <category><![CDATA[non-deep-networks]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[parnet]]></category>
            <dc:creator><![CDATA[Pranav Raikote]]></dc:creator>
            <pubDate>Mon, 22 Nov 2021 14:21:24 GMT</pubDate>
            <atom:updated>2021-11-22T14:21:24.926Z</atom:updated>
            <content:encoded><![CDATA[<h4>Is less the new more?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YECeOxlko9KoOJNw8RNm3A.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@alinnnaaaa?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Alina Grubnyak</a> on <a href="https://unsplash.com/s/photos/sparse-connections-network?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>Gone are the days when deeper networks used to rule the ML space with the Inceptions, ResNets, DenseNets, etc. which are now being replaced by even massive Transformer models. The industry always moved in the direction of more the better or deeper the better and it did work and produce groundbreaking results but at the cost of — Massive Computational cost, larger memory requirements, and the most important of all “<em>Carbon Footprint</em>” by training the huge models for days to together. <strong>Non-Deep Networks</strong> (also called <strong>ParNet</strong>) [1] have come for a good measure with an amazing performance of 80% top-1 accuracy, 96 % on CIFAR-10, and 81% on CIFAR-100 with just 12 layers! It is quite a feat and pushed me in writing this paper review.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*hoZcmPmTl6CmWPaF0KLhzA.jpeg" /><figcaption>Graph depicting the accuracy vs depth performance for ImageNet benchmark and the green dots are very impressive. Image Credits — Non-Deep Networks <a href="https://arxiv.org/pdf/2110.07641.pdf">paper</a></figcaption></figure><h3>Background</h3><p>There were days when a few 10s of layers were considered deep which has now grown 100x to upto 1000 layers deep networks. Of course, the accuracy and performance come with drawbacks in latency and parallelization. One more aspect I have noticed is that the modern models are rarely reproducible because of the cost and scale at which these models are built. And we have seen these architectures dominate the ImageNet benchmarks for a long time with the average depth constantly increasing for SOTA models. Things are starting to change surely.</p><blockquote>ParNet is matching the performance of the famed Vision Transformer with 12 layers!</blockquote><p>We have also seen a classic work in 1989 where the network was just a single layer with sigmoid activations that approximate a function very well. Here, when scaling, the width was increased which resulted in increased parameters. The other way to do this was the depth of the network which always approximated the function better without a huge increase in parameters and always outscored the “less” deep networks (even with a similar number of parameters too). Scaling a neural network conventionally involves increasing the depth, resolution, and width. On the contrary, the authors of ParNets have chosen parallel sub-architectures as their approach against the conventional method.</p><h3>Idea &amp; Architecture</h3><p>The intuition was to keep the layers constant at 12 and use parallelization to an extent they called the architecture “Embarrassingly parallel”. If we glance at the architecture depicted below, we see some <em>streams</em> (branches) with blocks that are more or less like the VGG model [2]. The blocks are called ParNet blocks where several (simple) things are happening internally. They chose the VGG-style because of its ability — Structural Reparameterization. Multiple 3x3 convolutional branches can be merged into a single 3x3 convolutional which can effectively reduce the inference times.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*aGJOVZwv_FHm_Pwim-Y3MA.jpeg" /><figcaption>ParNet architecture and ParNet Block. Image Credits — Non-Deep Networks <a href="https://arxiv.org/pdf/2110.07641.pdf">paper</a></figcaption></figure><p>Each ParNet block consists of 3 main components which are then merged /fused before the next block,</p><ol><li>1x1 convolution</li><li>3x3 convolutions and</li><li>SSE (<strong>Skip-Squeeze-and-Excitation</strong>) layer also called the RepVGG-SSE block</li></ol><p>Skip-Squeeze-Excitation block is depicted in the rightmost part of the above image. What it did essentially was, increase the receptive field without an increase in the depth aspect as opposed to the conventional Squeeze-Excitation [3] implementation. To induce more non-linearity than the ReLU activation in a shallow network size the authors chose to use the more recent SiLU [4].</p><p>Next comes the down-sampling and fusion blocks which reduce resolution and combine information from multiple streams respectively. Down-sampling results in an increase in width which facilitates multi-scale processing. This block is quite simple with a Squeeze-Excitation (SE) layer and an Average pooling attached to the 1x1 convolutional branch. The Fusion is no different from down-sampling except for an extra concatenation layer.</p><p>For scaling the network, experiments were conducted on the width, resolution, and the number of streams according to the datasets (CIFAR-10, CIFAR-100 &amp; ImageNet).</p><h3>Results &amp; Benchmarks</h3><p>The model was trained for 120 epochs on the ImageNet using the SGD optimizer with a few learning rate schedulers and decay values with a batch size of 2048 (pretty big). The learning rate was reduced in proportion with the batch size if it did not fit into memory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*U9UllfByqRBA8G1skV0KxQ.jpeg" /><figcaption>ParNet vs ResNet with the emphasis only the top-1 accuracy and speed. Image Credits — Non-Deep Networks <a href="https://arxiv.org/pdf/2110.07641.pdf">paper</a></figcaption></figure><p>The results of ParNet are on par or better than that of ResNets (Although the number of parameters is more because of the larger and extra-large scaled versions of ParNet).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*kkkZjx6ju2N7S6Qnm7Gf5Q.jpeg" /><figcaption>ParNet vs ResNet with the emphasis on the depth vs accuracy metric. Image Credits — Non-Deep Networks <a href="https://arxiv.org/pdf/2110.07641.pdf">paper</a></figcaption></figure><p>This shows that with just 12 layers the base ParNet can outperform a retrained ResNet-34 with the same procedure and augmentation used in ParNet in both top-1 and top-5 accuracy. Also, the ParNet-XL is outperforming the original ResNet-Bottleneck 101.</p><p>A separate section in the paper is dedicated to Parallelism and its advantages, do give that a read for more details. I will leave the Ablation studies section for you to explore and understand how the performance was boosted. Further, there are details on various outcomes of ResNets, ParNets, DenseNets, etc for the CIFAR-10 and CIFAR-100 datasets.</p><p>The authors were curious to test the ParNet as a backbone in the Object Detection networks and would it improve the existing performance? Looks like it does when ParNet replaced the Darknet53 [6] in YOLOv4 [7] both in terms of accuracy and latency.</p><h3>My Thoughts</h3><p>The ParNet can be implemented (and results reproducible) without the need for a massive infrastructure which is a welcome change. It opens the avenues for researchers to explore in this shallow depth parallel architecture space and bring out robust networks which might be suitable for edge-deployment scenarios without a great hit to performance.</p><p>Since it has shown promise in both Image Classification and Object Detection I’m very eager to see how it fares when transferred to a sensitive domain like healthcare. Will it be able to keep up with a considerable performance? Only time will tell.</p><h3>Conclusion</h3><p>ParNets showed us that going against the tide is rewarding. With a very shallow depth, it did not break a sweat when ascending the leader-board of the ImageNet classification benchmark [8]. It was for the first time that a network was able to excellently on three prominent datasets — CIFAR-10, CIFAR-100 [9] &amp; ImageNet with just 12 layers. The performance of ParNet increases with an increase in streams, resolution, and width keeping the depth constant. The authors also observed that the current performance is not saturated and can be scaled further.</p><h3>References</h3><p>[1] Non-Deep Networks: <a href="https://arxiv.org/pdf/2110.07641.pdf">https://arxiv.org/pdf/2110.07641.pdf</a></p><p>[2] VGG Network: <a href="https://arxiv.org/pdf/1409.1556.pdf">https://arxiv.org/pdf/1409.1556.pdf</a></p><p>[3] Squeeze-and-Excitation Networks: <a href="https://arxiv.org/pdf/1709.01507.pdf">https://arxiv.org/pdf/1709.01507.pdf</a></p><p>[4] SiLU activation: <a href="https://arxiv.org/pdf/1702.03118.pdf">https://arxiv.org/pdf/1702.03118.pdf</a></p><p>[5] DenseNet: <a href="https://arxiv.org/pdf/1608.06993v5.pdf">https://arxiv.org/pdf/1608.06993v5.pdf</a></p><p>[6] DarkNet53 in YOLOv3: <a href="https://arxiv.org/pdf/1804.02767v1.pdf">https://arxiv.org/pdf/1804.02767v1.pdf</a></p><p>[7] YOLOv4: <a href="https://arxiv.org/pdf/2004.10934v1.pdf">https://arxiv.org/pdf/2004.10934v1.pdf</a></p><p>[8] ImageNet benchmark: <a href="https://paperswithcode.com/sota/image-classification-on-imagenet">https://paperswithcode.com/sota/image-classification-on-imagenet</a></p><p>[9] CIFAR-10 &amp; CIFAR-100 datasets: <a href="https://www.cs.toronto.edu/~kriz/cifar.html">https://www.cs.toronto.edu/~kriz/cifar.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0b80c65c7c6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/non-deep-networks-b0b80c65c7c6">Non-Deep Networks</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[Expire-Span: Not All Memories are Created Equal explained]]></title>
            <link>https://medium.com/data-science/expire-span-not-all-memories-are-created-equal-explained-ffcbd9663bfd?source=rss-8143530c6291------2</link>
            <guid isPermaLink="false">https://medium.com/p/ffcbd9663bfd</guid>
            <category><![CDATA[attention-mechanism]]></category>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[facebook-ai-research]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Pranav Raikote]]></dc:creator>
            <pubDate>Wed, 23 Jun 2021 17:30:29 GMT</pubDate>
            <atom:updated>2021-06-23T17:30:29.705Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn to Forget by Expiring. Sometimes insignificant memories should be deleted to be better at a task?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rK4bpch2xhPwVUVsxBQVvg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@thatsherbusiness?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">That’s Her Business</a> on <a href="https://unsplash.com/s/photos/brain?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>Facebook AI Research has come up with a new architecture called Expire-Span [1] which sort of deletes contextual data which is deemed to be irrelevant information in the Attention [2] mechanism. Going by intuition, it should work well because we don’t want irrelevant information to be modelled and remembered especially when the sequence lengths are quite long these days. Let’s get into the details quickly because, the Expire-Span is training faster, using less memory, and can scale to very large sequence lengths without a drop in performance!</p><h3>Background</h3><p>Attention mechanism took the Deep Learning world by storm finding itself in a plethora of domains mainly NLP and Computer Vision. It is excellent in modelling long sequences very well and has set the benchmarks in most of the NLP tasks. Recently it made its way in Computer Vision — Vision Transformers [3] and GANs — Generative Adversarial Transformers [4] and TransGAN [5].</p><p>The performance comes at a cost — Heavy memory &amp; compute requirements! The research has now shifted from Attention mechanisms to reducing the usage of attention modules in the architectures because of its quadratic increase in computation when scaled with longer sequences. The MLP-Mixer showed us how to get away with the attention mechanism in Computer Vision tasks. I have already written a blog on MLP-Mixer [6], find it <a href="https://towardsdatascience.com/mlp-mixer-an-all-mlp-architecture-for-vision-7438fac99a06">here</a>. But doing away with attention in NLP tasks might be disastrous as the Attention mechanism has time and again proven that they are the best. There were several improved variants of Transformers like Adaptive-Span [7], Compressive Transformers [8], and Performers [9] which have tried to reduce the computation and memory overhead for longer sequences. Feel free to have a read about them. It is very interesting to study how the research is following around Attention mechanism in general.</p><p>In the above-listed architectures, one thing is constant,</p><blockquote>All memories are treated equally without the regards to their importance to the task</blockquote><p>quoted by the authors of Expire-Span as they set out to build an architecture that involves transformers but enables the architecture to forget the irrelevant things for that particular task. This will reduce the memory and computational overhead significantly resulting in a faster architecture and at times better than conventional attention-mechanism-based transformer architectures. The architecture they are comparing is Transformer XL [10] which is dividing the sequences into blocks and attending to the past from a readily available vector which is storing the attention information from the past blocks. Also used in the comparison are Adaptive Span and Compressive Transformer.</p><p><strong>Note</strong>: A good understanding of the Attention mechanism is recommended for this article.</p><h3>Idea &amp; Architecture</h3><blockquote>Is this time-step worth retaining or not? If not, then why not delete this and give more importance to the context which is more important and adding value to the task?</blockquote><p>This is the main idea that led to the conceptualization of Expire-Span. Deal-breaker isn’t it? Let’s try to understand the idea with a diagram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*McvhQxp1chJGwhZtiu_bMg.jpeg" /><figcaption>Conceptualization of Expire-Span. Image Credits — Expire-Span <a href="https://arxiv.org/pdf/2105.06548.pdf">paper</a></figcaption></figure><p>We can see some time steps <em>h</em>1, <em>h</em>1, <em>h</em>3, and so on till <em>h</em>t and 5 tokens with an expiration constant <em>e. </em>This expiration value ‘<strong><em>e</em></strong>’ denotes the no. of time steps after which the context information is deleted. In the above figure, <em>e</em>2 and <em>e</em>3 are not valid information as per the model and at time step ht, those are not factored or attended into the calculation at that particular step <em>t</em>. They are simply not adding enough contextual information going further and are deleted.</p><p>Conventionally transformers are attending to all the previous tokens for contextual information which is O(n²) computationally for a sequence length of n. If we consider a small example sentence “The dog sitting on the map”, we don’t want to carry the context of words the which is not adding much information and instead remember words <strong>dog </strong>and<strong> sitting</strong> for the word <strong>mat. </strong>This will lead to complexity less than O(n²), which is pursued hotly nowadays. Expire-Span is doing exactly this, giving more time steps for words “dog” and “sitting” than the word “the”. There will be a lower value of <em>e</em> for “the” than “dog”. This expiration of tokens is quite different from the fixed window attention which is sliding over the sequence and attending to a fixed length of tokens.</p><p>This is closely related to both Transformers and LSTMs [11] where we are attending to all tokens irrespective of their importance and smartly forgetting and retaining things in a sequence respectively. We can call Expire-Span a hybrid version of both :P</p><p>The Expire-Span value <strong><em>e </em></strong>is calculated by the formula given below,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/151/1*HRLxO3a3r-oZvRcEd-10SA.png" /><figcaption>Expire-Span formula. Image by Author</figcaption></figure><p>where <em>h</em>i is the memory step, w and b are trainable parameters and L is the maximum span. This eventually will determine for how long <em>h</em>i should be kept in the context (C<em>t</em>). There is one more equation <em>r</em>ti = <em>e</em>i − (t − i). Whenever the <em>r</em>ti value is negative, the <em>h</em>i is expired and can be removed from C<em>t</em>. The way it is implemented inside an attention layer is by a binary mask. We all know that there is an attention matrix that involves masking of values in the upper triangle while training transformers. This masking is extended to the lower triangle of the matrix too. We need to mask those cells also which are expired for that particular token in the attention matrix. The formula for this binary mask function <em>m</em>ti is given below,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/104/1*2TJGHM7DFoslOy_5vZK31w.png" /><figcaption>Binary Masking Function. Image by Author</figcaption></figure><p>This is not differentiable and there will be no gradients to train and hence a soft maxing function was used with the formula shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*Rl8GXEozy50n4bwPG-1c3Q.png" /><figcaption>Soft masking function. Image by Author</figcaption></figure><p>In the above formula R is a hyperparameter which is the length of the ramp bounded by 0 to 1. This will ensure that the mask is decreasing linearly after expiring at a particular time step. This is the gradient required to tune the <strong><em>e</em></strong> value during the training.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/212/1*wdFlXi7MSnYMeiJNWu_j8g.jpeg" /><figcaption>Soft masking visualization. Image Credits — Expire-Span <a href="https://arxiv.org/pdf/2105.06548.pdf">paper</a></figcaption></figure><p>There is also an L1 penalty added to the expire-span value <em>e</em> to decrease the span of memories that are not contributing to the main task which results in smaller memory usage which is highly focusing on the relevant information.</p><h3>Accommodation of Expire-Span in the existing Self-Attention Layers of Transformers</h3><p>The Expire-Span mechanism can be included within a self-attention layer with a few minor changes described below.</p><ol><li>The heads of self-attention share the same underlying memory and hence expire-span can be calculated per layer and shared across the heads</li><li>There is an adoption of a parallel block mechanism here which enables parallel computation and the hidden state values are cached and can be attended by future blocks</li><li>The chances of over-fit are high when the network can scale in tens of thousands in sequence length and this is countered by randomly shortening the memory span during training as a regularizing factor</li><li>The L value in the Expire-Span formula can take a very huge number and can exert a high influence on <em>e</em>. For very large values of L, the formula is modified as shown below to stabilize the training</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/186/1*dXbigK7Y0rvGxNIYlAzbqw.png" /><figcaption>Updated Expire-Span formula. Image by Author</figcaption></figure><h3><strong>Results &amp; Benchmarks</strong></h3><p>The model is trained on a variety of tasks like Corridor Task, Portal Task, Instruction Task (all are reinforcement learning tasks), Extreme Long Copy, Character level modelling, and Frame by Frame processing: Object Collision task. I will not go into detail about these tasks as the article will become too long and exhaustive. Instead, I will share one highlight of Expire-Span and few numbers which justify the usage of Expire-Span over other architectures for the above-mentioned tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*S87ZjtmvsjYbgufn_ngbug.jpeg" /><figcaption>Attention map of Enwik8 character level modelling. Image Credits — Expire-Span <a href="https://arxiv.org/pdf/2105.06548.pdf">paper</a></figcaption></figure><p>As we can see from the above diagram the model can remember proper nouns Egypt and Humpty Dumpty and if Egypt is replaced by the word “somewhere”, it is not given higher attention which will eventually not be attended by the future tokens (It is forgotten faster).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*KSGalTIXmuslteQVklDhww.jpeg" /><figcaption>Performance benchmarks of Expire-Span on Enwik8, PG-19 and Object Collision tasks. Image Credits — Expire-Span <a href="https://arxiv.org/pdf/2105.06548.pdf">paper</a></figcaption></figure><p>Expire-Span almost matches the performance levels of Transformer XL, Compressive Transformer, and Adaptive-Span with relatively low time/batch training time and GPU memory. Similarly, there are benchmarks given for Extreme long copy, Corridor and Instructions tasks too. Expire-Span is performing better than other models in terms of accuracy, memory, and scalability.</p><h3>My Thoughts</h3><p>The model must give an <em>e </em>value right when it encounters a word. The expire value might not be effective in modelling the first word throughout the document. Say, I have a word which is a name and very much important right till the end of a document. If the model gave a limited expire value, the contextual information for that word might be lost entirely.</p><p>At times you might infer in such a way that — This word is not that important going forward in this text. But after a while, that word which you forgot becomes very important and you try to remember where you had first seen it and what was its context then. The model assigns the <em>e</em> value independent of what happens in the future.</p><h3>Conclusion</h3><p>The Expire-Span is an architecture that can forget information not useful and irrelevant for the given data and task. This results in lower memory and compute requirements than the conventional transformers, enabling the architecture to scale to the lengths of tens and thousands! Despite consuming lesser memory and compute, it can match and few cases exceed the performance of state-of-the-art transformer architectures like Transformer XL, Adaptive Span, and Compressive Transformers. The research in this space is heading towards reducing or eliminating the attention mechanism for scalability, memory, and compute requirements (The carbon footprint left behind by training massive language model which uses an attention mechanism is huge and we need to think about that also).</p><p>Efficient Transformers: A Survey [12] is on the best ways to keep up with all the research which happened in the Transformers space over the years. I would highly recommend a read to this paper.</p><p>P.S: For more exciting technical blogs on AI, IoT and Bio visit <a href="https://appliedsingularity.com/blog/">https://appliedsingularity.com/blog/</a>!!!</p><h3>References</h3><p>[1] Not All Memories are Created Equal: Learning to Forget by Expiring: <a href="https://arxiv.org/pdf/2105.06548.pdf">https://arxiv.org/pdf/2105.06548.pdf</a></p><p>[2] Attention is all you need: <a href="https://arxiv.org/pdf/1706.03762">https://arxiv.org/pdf/1706.03762</a></p><p>[3] ViT (Vision Transformer): <a href="https://arxiv.org/pdf/2010.11929">https://arxiv.org/pdf/2010.11929</a></p><p>[4] Generative Adversarial Transformer: <a href="https://arxiv.org/pdf/2103.01209">https://arxiv.org/pdf/2103.01209</a></p><p>[5] TransGAN: <a href="https://arxiv.org/pdf/2102.07074">https://arxiv.org/pdf/2102.07074</a></p><p>[6] MLP-Mixer: <a href="https://arxiv.org/pdf/2105.01601">https://arxiv.org/pdf/2105.01601</a></p><p>[7] Adaptive Span: <a href="https://arxiv.org/pdf/1905.07799">https://arxiv.org/pdf/1905.07799</a></p><p>[8] Compressive Transformers: <a href="https://arxiv.org/pdf/1911.05507">https://arxiv.org/pdf/1911.05507</a></p><p>[9] Performers: <a href="https://arxiv.org/pdf/2009.14794">https://arxiv.org/pdf/2009.14794</a></p><p>[10] Transformer XL: <a href="https://arxiv.org/pdf/1901.02860">https://arxiv.org/pdf/1901.02860</a></p><p>[11] LSTM: <a href="https://www.bioinf.jku.at/publications/older/2604.pdf">https://www.bioinf.jku.at/publications/older/2604.pdf</a></p><p>[12] Efficient Transformers: A Survey: <a href="https://arxiv.org/pdf/2009.06732.pdf">https://arxiv.org/pdf/2009.06732.pdf</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ffcbd9663bfd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/expire-span-not-all-memories-are-created-equal-explained-ffcbd9663bfd">Expire-Span: Not All Memories are Created Equal explained</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[MLP-Mixer: An all-MLP Architecture for Vision]]></title>
            <link>https://medium.com/data-science/mlp-mixer-an-all-mlp-architecture-for-vision-7438fac99a06?source=rss-8143530c6291------2</link>
            <guid isPermaLink="false">https://medium.com/p/7438fac99a06</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Pranav Raikote]]></dc:creator>
            <pubDate>Mon, 07 Jun 2021 03:14:26 GMT</pubDate>
            <atom:updated>2021-06-07T12:36:20.866Z</atom:updated>
            <content:encoded><![CDATA[<h4>Back to the good old MLP?</h4><h3>Introduction</h3><p>Researchers from the Google Research &amp; Google Brain teams released a new architecture MLP-Mixer which is not featuring CNN or Attention Layers but still can achieve a performance that is on-par with architectures like ViT (Vision Transformer), BiT (Big Transfer), HaloNet, and NF-Net. It does so with a 3x speedup in training and scales excellently with the amount of training data. The authors have put together this architecture because they feel we can achieve excellent results without the all-important CNN and Attention layers which are computation hungry. In this process, they also demonstrate a higher throughput/second/core and how well the model scales for bigger datasets better than most of the current state-of-the-art.</p><h3>Background</h3><p>Until this paper was published, CNNs and Self-Attention were the go-to mechanisms for Image Classification and Computer Vision in general. This was showcased in the recent state-of-the-art Vision Transformer (ViT) which was successful in using a Transformer with Attention layers applied for Computer Vision tasks. While these operations are very computationally intensive taking multiple days to train on TPUs, the authors propose something which is a fundamental concept in Deep Learning — The MLP (Multi-layered Perceptron)! The architecture relies on a variety of matrix multiplications repeatedly on spatial and feature channels.</p><p>How is that possible? Didn’t we move on from MLPs, CNNs, Residual CNNs i.e. ResNets, DenseNets, NF-Nets, ViT, and so on…? Now, the authors are saying come back to MLP? Yes, you heard them right,</p><blockquote>While convolutions and attention are both sufficient for good performance, neither of them are necessary</blockquote><p>These are huge claims, let us understand why this architecture worked and their claims are right!</p><h3>Architecture</h3><p>Coming to the MLP-Mixer model, quite a few things are going on. We have the input in form of patches, just like how it is for ViT. Then there is a Mixer Layer wherein two operations are happening, the fully connected layers with GELU activations, and finally a linear classification head. Skip-connections and regularization like Dropout and Layer Norm also make their way into the architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*-LddwW7LDDTLrl3CrKDXmQ.jpeg" /><figcaption>MLP-Mixer architecture. Image Credits — MLP-Mixer <a href="https://arxiv.org/pdf/2105.01601.pdf">paper</a></figcaption></figure><p>As we see at the bottom of the architecture, the input to the network is in form of image patches. These patches are projected linearly into an H-dimension latent representation (which is hidden) and passed on to the Mixer layer. One thing to note here is the H value is independent of the number of patches or patch sizes which enabled the network to grow linearly instead of quadratically in the case of ViT. This resulted in reduced computational parameters and a higher throughput of about 120 images/sec/core which is almost 3x than ViT’s 32 images/sec/core.</p><p>Now, things get interesting. Referring to the top part of the image which is showcasing the Mixer layer, the patches when projected are converted into a table-like form which we will call X. The patches are layered out on top of each other.</p><p>The Mixer layer consists of 2 MLP blocks. The first block (token-mixing MLP block) is acting on the transpose of X, i.e. columns of the linear projection table (X). Every row is having the same channel information for all the patches. This is fed to a block of 2 Fully Connected layers. This block holds the same type of information — Identify features in the image across patches i.e aggregate all channels where this feature occurs. The weights are shared here in the MLP 1 layers shown in the image.</p><p>The second block (channel-mixing MLP block) is acting on the rows after another transpose of X. Here, each patch is taken and apply computation across all channels of the patch. This is looking for features only in that patch and associating it with the channel, whereas in token-mixing block it is searching for features in all the channels.</p><p>This architecture is a unique CNN as quoted by the authors,</p><blockquote>Our architecture can be seen as a unique CNN, which uses (1×1) convolutions for channel mixing, and single-channel depth-wise convolutions for token mixing. However, the converse is not true as CNNs are not special cases of Mixer.</blockquote><p>Also, the architecture uses Layer Norm which is often found in Transformer architectures. Below image illustrates Layer Norm vs BatchNorm for a quick understanding. More on Layer Norm <a href="https://leimao.github.io/blog/Layer-Normalization/">here</a>. There are skip connections included with the GELU activation for non-linearity and dropout for regularization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*tTHI_aZSsxj9X4-EdHnT2Q.jpeg" /><figcaption>Layer Normalization vs Batch Normalization. Image Credits — PowerNorm <a href="http://proceedings.mlr.press/v119/shen20e/shen20e.pdf">Paper</a></figcaption></figure><h3>Benchmarks and Results</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*PGbhkRNTieQch3-APf7SKQ.jpeg" /><figcaption>Comparison of Mixer with other models across datasets. Image Credits — MLP-Mixer <a href="https://arxiv.org/pdf/2105.01601.pdf">paper</a></figcaption></figure><p>As we see in the table, the performance in terms of ImageNet top-1 validation accuracy is quite good when compared with other SOTAs. But the real deal for MLP-Mixer is two-fold — Throughput of images/sec/core and TPU training time. And the Mixer is far ahead of ViT in terms of throughput of images/sec/core with a score of 105 to the ViT’s 32 (ImageNet) and scores a good 40 images/sec/core against the ViT’s 15 images/sec/core (JFT-300).</p><p>The ViT outperforms Mixer when it comes to TPU training time on ImageNet but not JFT-300. So, as we observe more numbers on the table, we can say that the “Mixer-MLP is out there and challenging the other SOTAs. Not necessarily outperforming them, but yeah still very much competitive”.</p><p>Coming to the part where “It scales with more data”, the below graph illustrates the performance of Mixer, ViT, and BiT when the training set size increases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/1*wvPEMaBQwF1a0OoGbxPBFA.jpeg" /><figcaption>Training subset size vs ImageNet top-1 val accuracy. Image Credits — MLP-Mixer <a href="https://arxiv.org/pdf/2105.01601.pdf">paper</a></figcaption></figure><p>The Mixer is closely matched at the right side of the graph which is indicating 5-shot ImageNet top-1 accuracy. But we need to observe the curves from the left side where the training subset size starts from 10M and goes all the way to 300M. In all the cases, Mixer has a better curve scaling and doesn’t flat-line the curve at any point in time. This means, it is not getting saturated with more training data, whereas ViT and BiT models are saturating (accuracy not improving) once they pass the 100M training data subset size.</p><p>Also, in the other full-blown comparison of all variants of the model with other SOTAs considering the pre-training aspect which is correlating to the performance, Mixer benefits when there is more data. Smaller the pre-training data, larger is its gap to SOTAs in terms of validation accuracy. make sure to have a look at this in the paper. Also in the paper is a section very interesting — <strong>How MLP-Mixer’s design idea can be traced back to CNNs &amp; Transformers?. </strong>That’s why make sure to give the paper a read for the ablations, related works, different experiment setups, visualization of the weights, and things that did not work out!</p><h3>Conclusion</h3><p>The MLP-Mixer is right there on top in various important metrics like throughput and training time. It is not far behind in terms of ImageNet top-1 validation accuracy with a score of 87.78 when pre-trained on JFT-300. The network scales excellently when compared to ViT &amp; BiT for the amount of training data provided. However, there is one point to ponder — Inductive Bias. According to the training subset size vs ImageNet top-1 val accuracy graph in the paper, ViT flattens out at the 300M mark whereas Mixer-MLP is still on the rise. What might happen if the scale of data is 600M? Keep a close eye on the role of pre-training dataset sizes and the inductive biases. Having said that, one more interesting comment by the authors is — “Whether this design holds good for NLP?”. Time will tell.</p><h3>References</h3><p>[1] MLP-Mixer: <a href="https://arxiv.org/pdf/2105.01601.pdf">https://arxiv.org/pdf/2105.01601.pdf</a></p><p>[2] ViT: <a href="https://arxiv.org/pdf/2010.11929">https://arxiv.org/pdf/2010.11929</a></p><p>[3] BiT: <a href="https://arxiv.org/pdf/1912.11370">https://arxiv.org/pdf/1912.11370</a></p><p>[4] HaloNet: <a href="https://arxiv.org/pdf/2103.12731">https://arxiv.org/pdf/2103.12731</a></p><p>[5] Layer Norm: <a href="https://arxiv.org/pdf/2003.07845">https://arxiv.org/pdf/2003.07845</a></p><p>[6] NF-Nets: <a href="https://arxiv.org/pdf/2102.06171v1.pdf">https://arxiv.org/pdf/2102.06171v1.pdf</a></p><p>[7] ImageNet: <a href="http://www.image-net.org/">http://www.image-net.org/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7438fac99a06" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/mlp-mixer-an-all-mlp-architecture-for-vision-7438fac99a06">MLP-Mixer: An all-MLP Architecture for Vision</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[NF-Nets : Normalizer Free Nets]]></title>
            <link>https://medium.com/analytics-vidhya/nf-nets-normalizer-free-nets-95648703109a?source=rss-8143530c6291------2</link>
            <guid isPermaLink="false">https://medium.com/p/95648703109a</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[research]]></category>
            <category><![CDATA[batch-normalization]]></category>
            <category><![CDATA[image-classification]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Pranav Raikote]]></dc:creator>
            <pubDate>Sun, 07 Mar 2021 13:52:07 GMT</pubDate>
            <atom:updated>2021-03-10T16:52:29.759Z</atom:updated>
            <content:encoded><![CDATA[<h3>NF-Nets : Normalizer Free Nets</h3><p><em>The beginning of the downfall for Batch Normalization?</em></p><h3>Introduction</h3><p>DeepMind released a new family of state-of-the-art networks for Image Classification that has surpassed the previous best — <a href="https://ai.googleblog.com/2019/05/efficientnet-improving-accuracy-and.html">EfficientNet</a> — by quite a margin. The main idea behind the new architecture is the use of Normalizer Free Neural Nets or NF-Nets to train networks instead of batch normalization, which is still widely used in almost every other neural net because of its rich set of advantages. <strong>The NF-Net-F1 matches the accuracy of EfficientNet-B7 while being 8.7x faster to train! </strong>Given below is the Accuracy vs Latency graph of the most recent state-of-the-art architectures for image classification on the ImageNet dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/0*zGkALdvhSUrboDl0.jpeg" /><figcaption>As we can see here, NFNet-F0 almost matches the accuracy of EfficientNet-B5 and goes on to beat EfficientNet-B7 comprehensively with its NFNet-F5. Image Credits — NFNet <a href="https://arxiv.org/pdf/2102.06171v1.pdf">Paper</a>.</figcaption></figure><blockquote>There will be a paradigm shift towards Neural Nets not using Batch Normalization anymore</blockquote><h3>Background</h3><p>Almost all neural networks, especially in the Computer Vision-Image Classification domain, heavily rely on Batch Normalization for training deep networks. May it be the smoothing of loss, reducing covariate shift, or the regularization effect, Batch Normalization has always given an unprecedented advantage in training a neural-net, till now. That’s about to change! The authors of NF-Net showed that we can train Deep Residual Networks without Batch Normalization by replacing it with a few other techniques that will lead to faster training and better accuracy than Batch Normalization-enabled networks. NF-Nets were faster to train and could have a batch-size of up-to 4096! But before diving into the details of the new alternatives and techniques, let’s first set the<strong> context</strong> by having a small walk-through of Batch Normalization.</p><h3>Batch Normalization</h3><p>Just as a quick recap, Batch Normalization is a method to train very deep networks like ResNet by standardizing the inputs for each mini-batch. There was a problem observed called internal covariate shift, which is the change of distribution of inputs between the layers, and it looked like the network was training towards a moving target. This is because neural nets are quite sensitive to the initial weights and the algorithm. Batch normalization solved this in the initial stages to a significant extent by shifting the inputs with a calculated mean and variance parameters that smoothen the loss landscape and stabilize the training.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*4npPWeCwGtvnHcSX.jpeg" /><figcaption>Batch Normalization illustration.</figcaption></figure><p>The below image shows the various steps and formulae in the Batch Normalization procedure for each mini-batch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/0*GqOEZ30d3qCLiUqb.jpeg" /><figcaption><em>The sequential steps performed in Batch Normalization operation — Mean, Variance, Normalization, and Scale &amp; Shift. The gamma and beta parameters are learnable parameters in the neural network. Image from </em><a href="https://arxiv.org/pdf/1502.03167.pdf"><em>paper</em></a><em>.</em></figcaption></figure><h4>Pros of Batch Normalization</h4><ol><li>It is hugely successful in <strong>down-scaling the hidden activations</strong> when training deep ResNets (ResNet, ResNeXt, etc) consisting of 1000s of layers. How? Batch normalization when used on the residual branch was effective in scaling down the activation outputs. On the other hand, when Batch normalization was applied to the skip branch, it induced a slight bias towards the residual branch. This ensured that the initial training was stable and led to efficient optimizations.</li><li><strong>It eliminates the mean shift effect </strong>when non-zero mean activations are outputted by functions like ReLU &amp; GELU. The main issue was, as the network went deeper, the mean-activation got larger and more positive, which led to the network predicting the same labels for all training samples and the training unstable. Batch normalization solves this by making sure that the mean-activation is zero across all layers.</li><li>It has a <strong>good regularizing effect</strong> and it can replace Dropout as a regularizing factor while training neural nets. The networks trained with Batch Normalization do not overfit easily and generalize well for any given data sample. This is mainly due to normalizing the noisy batch stats. Also, the validation accuracy can be improved by tuning the batch size.</li><li>It can <strong>train neural nets with bigger batch sizes and larger learning rates</strong>. Since the loss landscape is smooth, larger and stable learning rates can be used for training. This might not be efficient for smaller batch sizes. Also, it achieves the same accuracy in fewer steps compared to a non-batch normalized neural net, thereby improving the training speed.</li></ol><h4>Cons of Batch Normalization</h4><ol><li>It can be <strong>computationally intensive</strong> in a few networks due to the calculation of mean and scaling parameters and storing them for the back-prop step.</li><li>There can be <strong>discrepancies between the behavior of the network during training and testing times. </strong>While training, the network might have learned and trained to certain batches, which makes the network dependent on that batch-wise setup. So it might not perform well when a single example is provided at inference.</li><li>Batch normalization <strong>breaks the independence between examples within a batch. </strong>This means the examples selected in a batch are significant and lead us to two more prospects — <strong>Batch Size matters </strong>and inefficient <strong>Distributed Training </strong>that will lead to the network cheating the loss function.</li><li>Batch size matters because in a small batch, the mean approximate is going to be noisy whereas in a bigger batch the approximation may be worth considering. It has been observed that larger batches lead to stable and efficient training. <strong>Also, the performance of Batch Normalized networks can degrade if the stats have a large variance while training.</strong></li><li>Coming to the second point of cheating loss functions, difficult distributed training, and replication of results in another hardware, when we distribute the training in parallel streams, each stream will receive a portion or shard of a batch and a forward pass is applied. The discrepancy comes when there is no communication between the Batch Normalization layers i.e. all the streams will calculate the mean and variance parameters independently. This is wrong because the parameters are not holding true for the entire batch but rather for each shard, which leads to <strong>cheating</strong> the loss function.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*fBJP07l8_vvWSkub.png" /><figcaption>Illustration of Distributed training required in case of BatchNormalization present in the neural net.</figcaption></figure><h3>Background for NF-Nets</h3><p>From the above discussion on Pros and Cons, we understand that although Batch Normalization has been instrumental in training deep networks, there are major disadvantages, and the authors put forward the idea of heading towards a new direction of Neural Nets free of batch normalization. The way to achieve this was to replace batch norm by suppressing the hidden activations on the residual branch. The authors of this [ <a href="https://arxiv.org/pdf/2101.08692.pdf">Paper</a>] implemented a normalizer-free ResNet by suppressing the residual branch at initialization and using <strong>Scaled Weight Standardization. </strong>Weight Standardization controls the first and second moments of the weights of each output channel individually in convolutional layers. Weight Standardization standardizes the weights in a differentiable way which aims to normalize gradients during back-propagation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/228/0*UaZ2uWb0CUVao3JV.png" /><figcaption>Scaled Weight Standardization.</figcaption></figure><blockquote>where μ and σ refer to the mean and standard deviation of the weights, and N refers to the f-in of the convolutional layer</blockquote><p>These nets ( <strong>NF-ResNet</strong>) were able to match the accuracy of Batch Normalized ResNets but struggled with larger batch sizes and failed to match the current state-of-the-art EfficientNet. <strong>NF-Nets are built on top of this research work.</strong></p><h4>Main Contributions of the Research</h4><ol><li>The authors propose a new method, <strong>Adaptive Gradient Clipping,</strong> which can be used to clip the gradient based on the unit-wise <strong><em>ratio of gradient norms and parameters norms</em></strong> allowing training of NF-Nets with larger batches and stronger data augmentations.</li><li>It introduced a <strong>family of Normalizer-free ResNets</strong>, NF-Nets which surpass the results of the previous state-of-the-art architecture, EfficientNets. The largest NF-Net model achieved a top-1 accuracy of 86.5% (new state-of-the-art) without the use of extra data!</li><li>It shows that the <strong>NF-Nets outperform the Batch Normalized networks</strong> in terms of validation accuracies when fine-tuned on ImageNet. The top-1 accuracy post fine-tuning is 89.2%</li></ol><p><strong>Let us understand the main highlight of the paper i.e. Adaptive Gradient Clipping</strong></p><h3>Adaptive Gradient Clipping</h3><p>Before going into Adaptive Gradient Clipping or ADC in short, what is gradient clipping? Gradient Clipping is a method to limit a huge change in gradient values either positively or negatively. To put it in simple terms, we don’t want the gradient to take big jumps while finding the global minima. We simply clip off the gradient value when it is too much. But, we also have to accommodate the scenario where the gradient has to be large enough to come out from the local minima or correct its course while traversing through the loss landscape. If the path of the resultant is good enough, we will get it again for sure, but on the other hand if it is a bad gradient, we want to limit its impact.</p><p>The authors hypothesize that gradient clipping will enable the training of NF-Nets with a large batch size and larger learning rate. This is because of previous works in Language Modelling [ <a href="https://arxiv.org/pdf/1708.02182.pdf">Paper</a>] to stabilize the training and it also allows the usage of larger learning rates, thereby accelerating the training. The standard gradient clipping [ <a href="https://arxiv.org/pdf/1211.5063.pdf">Paper</a>] is given by,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/0*Z2pRCUeitvExPGTL.png" /><figcaption><em>Standard Gradient Clipping.</em></figcaption></figure><p>where G is the gradient vector, G = ∂L/∂θ, where L denotes the loss and θ denotes a vector with all model parameters. This clip is done before updating the θ. The lambda (λ) is the clipping threshold hyperparameter that must be tuned. The authors observed that this hyperparameter is very highly influential for the training (training stability was extremely sensitive to the clipping threshold value chosen) and hence required very fine-grained tuning. To counter this, they introduced <strong>Adaptive Gradient Clipping or ADC</strong>.</p><p>The gist of ADC is that it clips the gradient w.r.t this particular ratio — norm of Gradients G^ <em>l</em> to the norm of Weights W^ <em>l</em> for the layer <em>l</em> (How large the gradient is / How large the weight is that the gradient acts upon). This will give a measure of the change in the gradient step that will change the original weights. Specifically, each unit <em>i </em>of the gradient of the <em>l-</em>th layer — G( <em>l)(i) </em>given by,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/0*XxKSemD24i_6uYHB.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/0*xCrec5wsHUpBoWgB.png" /><figcaption>Adaptive Gradient Clipping formula.</figcaption></figure><p>where epsilon = 10^-3 to prevent the zero-initialized parameters to be clipped back to 0. With the usage of AGC, it enabled training neural networks stably with batch sizes of 4096, which is quite a massive number for a batch. λ, which is the clipping parameter, is set depending upon the optimizer, learning rate, and batch size. The below image depicts the scaling of NF-Nets for larger batch sizes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/0*mY8q07lqmWPxwmrU.jpeg" /><figcaption><em>As we see, it holds out well till 4096, but the max observed accuracy has its<br>batch size around 2048. Image taken from the </em><a href="https://arxiv.org/pdf/2102.06171v1.pdf"><em>paper</em></a><em>.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/0*RaSUgaoWT4Ujr1Aw.jpeg" /><figcaption><em>The clipping threshold of 0.02 holds good and gives the maximum possible accuracy.<br>Image taken from the </em><a href="https://arxiv.org/pdf/2102.06171v1.pdf"><em>paper</em></a><em>.</em></figcaption></figure><p>Empirically, it was found that <strong>a lower clipping threshold holds good for larger batch sizes. </strong>Consider a large batch size, where the batch stats are not that noisy. Here the clipping must be set low, else it will collapse. Likewise, if the batch size is very small, there might be more noise in the batch stats and we can get away with a higher clipping threshold.</p><h3>Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*AA0XrwYcH8DHkDYR.jpeg" /><figcaption><em>NF-Net architecture. Image taken from </em><a href="https://arxiv.org/pdf/2102.06171v1.pdf"><em>paper</em></a><em>. Left-Image depicts transitional block and right-Image depicts non-transitional block.</em></figcaption></figure><p>Coming to the architecture, NF-Net is a modified version of SE-ResNeXt-D [ <a href="https://arxiv.org/pdf/1709.01507.pdf">Paper</a>]. The model has an initial “stem” comprised of a 3×3 stride-2 convolution with 16 channels, two 3×3 stride-1 convolutions with 32 channels and 64 channels respectively, and a final 3×3 stride-2 convolution with 128 channels. The activation function used here is GELU [ <a href="https://arxiv.org/pdf/1606.08415.pdf">Paper</a>] which performs as good as ReLU &amp; SiLU.</p><p>The Residual stages consist of two types of blocks, starting with a transitional block and followed by the non-transitional block. All blocks employ the pre-activation ResNe(X)t bottleneck pattern with an added 3×3 grouped convolution inside the bottleneck. Following the last 1×1 convolution is a Squeeze &amp; Excite layer which globally average pools the activation, applies two linear layers with an interleaved scaled non-linearity to the pooled activation, applies a sigmoid, then rescales the tensor channel-wise by twice the value of this sigmoid.</p><p>After all of the residual stages, we apply a 1×1 expansion convolution that doubles the channel count. This layer is primarily helpful when using very thin networks, as it is typically desirable to have the dimensionality of the final activation vectors (which the classifier layer receives) be greater than or equal to the number of classes. Coming to the final layer, it outputs a 1000-way class vector with learnable biases. This layer has its weights initialized to 0.01 and not 0.</p><p>The <strong>important</strong> feature of NF-Nets is <strong>“Normalizer Free”. </strong>The input to the main path of the residual block is multiplied by 1/β, where β is the predicted value of the variance at that block at initialization, and the output of the block is multiplied by a scalar hyperparameter α, typically set to a small value like α = 0.2. These scalars α and β are very instrumental in achieving the Normalizer Free implementation. The formulae are given below,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/0*EEZeM-WGjB7od9Gf.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/311/0*Jn4Myx6zlGZWv-tq.png" /><figcaption><em>Unit Signal Variance at the beginning of each stage.</em></figcaption></figure><p>The model and its configurations are quite complex and going through the paper will help if you’re replicating/implementing the NF-Nets. The experiments also are a tad lengthy and to keep it short and crisp in this blog, I have not included the experiments and ablation studies.</p><h3>Benchmarks and Results</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/0*4_p634ALJY5IQO2q.jpeg" /><figcaption><em>Comparison between NF-ResNet and BN-ResNet (Batch Normalized-ResNet) with various image size in pixels. Image taken from the </em><a href="https://arxiv.org/pdf/2102.06171v1.pdf"><em>paper</em></a><em>.</em></figcaption></figure><p>As we see, NF-Nets outperform their Batch Normalized counterparts. <strong>The NF-Net-F5 model achieved a top-1 validation accuracy of 86%, improving over the previous state-of-the-art results. And behold, we have the NF-Net as the new state-of-the-art network</strong>, whereas the NF-Net-F1 model matches the EfficientNet-B7’s score of 84.7% (all depicted in the below table).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*Abhg6OdP9tBt6rze.jpeg" /><figcaption><em>Comparison of various architectures with training times. Image taken from </em><a href="https://arxiv.org/pdf/2102.06171v1.pdf"><em>paper</em></a><em>.</em></figcaption></figure><h3>Problems which may not yet be solved</h3><ol><li>The training examples are still implicitly dependent on the batch if we observe how the <strong>implementation</strong> is done: Clipping after the averaging operations for that batch.</li><li>The observation of different behaviors in train and test time was quoted as one of the problems of Batch Normalization. But here, in the implementation, they have used Dropout, which also has different behavior in train and test times.</li></ol><h3>Conclusion</h3><p>To conclude, there were a lot of things going on in this paper, but few were very significant for the successful development of Normalizer Free Neural Nets. The introduced NF-Nets surpassed the performance of the latest state-of-the-art for Image Classification (without using extra data) and was also faster to train. It was also shown that the family of NF-Nets is better-suited for fine-tuning on large datasets than the batch normalized variants.</p><h3>References</h3><ol><li>NF-Net: <a href="https://arxiv.org/pdf/2102.06171v1.pdf">https://arxiv.org/pdf/2102.06171v1.pdf</a></li><li>EfficientNet: <a href="https://arxiv.org/pdf/1905.11946.pdf">https://arxiv.org/pdf/1905.11946.pdf</a></li><li>Batch Normalization: <a href="https://arxiv.org/pdf/1502.03167.pdf">https://arxiv.org/pdf/1502.03167.pdf</a></li><li>ImageNet: <a href="http://www.image-net.org/">http://www.image-net.org/</a></li><li>ResNet: <a href="https://arxiv.org/pdf/1512.03385.pdf">https://arxiv.org/pdf/1512.03385.pdf</a></li><li>ReLU: <a href="https://arxiv.org/pdf/1811.03378.pdf">https://arxiv.org/pdf/1811.03378.pdf</a></li><li>GELU: <a href="https://arxiv.org/pdf/1606.08415.pdf">https://arxiv.org/pdf/1606.08415.pdf</a></li><li>Unnormalized ResNet: <a href="https://arxiv.org/pdf/2101.08692.pdf">https://arxiv.org/pdf/2101.08692.pdf</a></li><li>Regularizing and Optimizing LSTM Language Models: <a href="https://arxiv.org/pdf/1708.02182.pdf">https://arxiv.org/pdf/1708.02182.pdf</a></li><li>Gradient Clipping &amp; Regularization: <a href="https://arxiv.org/pdf/1211.5063.pdf">https://arxiv.org/pdf/1211.5063.pdf</a></li><li>SE-ResNeXt-D (Squeeze &amp; Excitation Networks): <a href="https://arxiv.org/pdf/2102.06171v1.pdf">https://arxiv.org/pdf/2102.06171v1.pdf</a></li></ol><p><em>Originally published at </em><a href="https://appliedsingularity.com/2021/03/07/nf-nets-normalizer-free-nets/"><em>http://appliedsingularity.com</em></a><em> on March 7, 2021.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95648703109a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/nf-nets-normalizer-free-nets-95648703109a">NF-Nets : Normalizer Free Nets</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[Spiking Neural Networks]]></title>
            <link>https://pranavraikote.medium.com/spiking-neural-networks-307ea1a6a7e2?source=rss-8143530c6291------2</link>
            <guid isPermaLink="false">https://medium.com/p/307ea1a6a7e2</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[spiking-neural-network]]></category>
            <category><![CDATA[neural-networks]]></category>
            <dc:creator><![CDATA[Pranav Raikote]]></dc:creator>
            <pubDate>Sun, 31 May 2020 17:32:07 GMT</pubDate>
            <atom:updated>2020-08-31T12:32:07.258Z</atom:updated>
            <content:encoded><![CDATA[<p>When we talk about Artificial Neural Networks, we talk about them inspired by the working of the human brain. But, they are static and have continuous-valued activation as opposed to what’s happening in the brain. It gave birth to a new class of Neural Networks — <strong>Spiking Neural Networks</strong>! In a Human brain, biological neurons send discrete spikes to transmit and compute information. These neural nets attempt to mimic the neuron spikes happening in the brain. Here, the spike rates and spike times matter a lot in this approach.</p><p>These networks take continuous inputs and give continuous outputs and are fully connected. This class aims to bridge the gap between Deep Learning/Machine Learning and Neuroscience, using biologically realistic models that will try to mimic the brain in structure and way of transmitting and computing neural signals. The neurons won’t fire at each cycle of propagation instead will do when a certain potential is reached. It forms like a chain reaction where they are transmitting and increasing/decreasing the potential at the next neuron.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/0*HYcme5008SIwz-ZV" /><figcaption>Google</figcaption></figure><p>This seems cool but why it has not yet become a huge revelation in the Deep Learning/Machine Learning Community? There is one major hurdle in this architecture — How to make it learn? General consensus says Back-propagation. But here the Spiking Neuron is represented by the sum of Dirac delta functions — A function that is zero everywhere except one point and at that point, it can be thought of as either undefined or as having infinite value. So, the most important <strong>derivative</strong> does not exist here at all!!! This was addressed by using approximate derivatives, research is still happening on this major issue.</p><p>SpikeProp came into existence where the back-propagation issue was solved where the cost function used was spike timing and they were successful in training a SNN for non-linearly separable XOR problem with 3 Layers. They associated late and early firing times are 0 and 1 respectively which were fed after temporal encoding. Synaptic delays were mapped to the connection delay and they had a range from 0ms to 15ms (Delay Interval). They achieved really good accuracy metric of 97%+ for Wisconsin and Iris datasets.</p><p>Today, research is actively going on developing Spiking CNNs, Spiking RNNs, Spiking DBNs (Deep belief Networks). While the current Deep Learning Models continue to be computationally heavy and massive architecture with an onwards of more than 1 billion parameters also, Spiking Neural Nets are light weight on the aspect of computation because of the sparse spike based framework. They demand new neuron models to biological represent the neural architecture and it’s working. Current research is happening on how can we build hybrid Deep Learning models where SNN and the existing framework can be used to leverage advantages of both class of networks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/80/0*lfHf_w79NzLMMOMx" /></figure><p>Tech enthusiast <a href="https://ptechnologyblog.wordpress.com/author/pranavraikote/">View all posts by Pranav Raikote</a></p><p><strong>Published</strong></p><p><em>Originally published at </em><a href="https://ptechnologyblog.wordpress.com/2020/05/31/spiking-neural-networks/"><em>http://ptechnologyblog.wordpress.com</em></a><em> on May 31, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=307ea1a6a7e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Self Supervised Learning & Auto-encoders]]></title>
            <link>https://pranavraikote.medium.com/self-supervised-learning-auto-encoders-e34a378bd4fc?source=rss-8143530c6291------2</link>
            <guid isPermaLink="false">https://medium.com/p/e34a378bd4fc</guid>
            <category><![CDATA[autoencoder]]></category>
            <category><![CDATA[self-supervised-learning]]></category>
            <category><![CDATA[deep-autoencoder]]></category>
            <dc:creator><![CDATA[Pranav Raikote]]></dc:creator>
            <pubDate>Sun, 24 May 2020 06:08:24 GMT</pubDate>
            <atom:updated>2020-08-31T12:31:25.660Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s been long since my last blog post! Was into full-on research mode for quite a few months. But, I’m back with a topic which is less heard in all the Deep Learning and Neural Network world. Yeah, I’m talking about a seldom-used terminology called self-supervised Learning. Let’s understand why this class of Neural Networks falls into this category of Learning.</p><h3>Self Supervised Learning</h3><p>When we have Labeled Data, we call it Supervised Learning. If data doesn’t have any labels, then it is Unsupervised Learning. What’s this Self Supervised Learning boss?? Here the input data and output data are the same. Hence, there is only one label in training and the neural net figures what is the data. This neural net takes in an input image and tries to output the same image. So, now comes the big question — What’s the use of this? It compresses the Input Image into a Latent Space Representation and tries to generate the Image from this Latent Space Representation. It was also called Reduced Data Dimensions. Let’s understand this.</p><p>Latent Space means a representation of compressed data. Suppose we have an image and representing in its Latent space will involve compressing and bring all similar data points more closer to each other. This is hugely useful for learning data features and finding similar patterns called Representation Learning. Technically an Image in Latent Space Representation will be like a single vector that compresses and quantifies the Input Image. Now, let’s see how these neural nets are built.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/0*D-E5s22_pKgu46-0" /><figcaption>Towards Data Science</figcaption></figure><h3>Auto-encoders</h3><p>Auto-encoders are the class of Neural nets that are used for this task — Image Compression and Reconstruction. It was like an identity function — learns to output whatever was inputted. It was like basically compressing and encoding the data into a Latent Space representation and then learn/attempt to reconstruct the original image. So, this was called as Encoder-Decoder architecture. The 4 main components were — Encoder, Decoder, Bottleneck (Layer which contained the compressed representation), and the Reconstruction Loss.</p><p>Auto-encoders can be easily built — The Encoder is usually a series of Convolution and Max Pooling Layers till we reduce to a small dimension and that layer becomes the encoding layer. Meanwhile the Decoder is connected to this encoded layer and Up-sampling Layers are used to get it back to the Original dimensions. Auto-encoders are data-specific, meaning you need to provide a similar set of data to be trained or to be used properly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/0*uvtNB8WoAKTfRkyq" /><figcaption>Towards Data Science</figcaption></figure><h3>Applications</h3><p>Now, what is the real use of this Auto-encoder? The real deal here is Dimensionality Reduction, Outlier Detection, and Denoising. Image Denoising is by far the most used application of Auto-encoders. It gives excellent results when it comes to removing the noise from an image. If we talk about applications outside the Computer Vision world, then we have Sequence-to-Sequence Encoders, which learn the temporal structure of the input sequences rather than an image. One of the most recent Auto-encoders is Variational Auto-encoders. Instead of learning an arbitrary function, you make it learn a latent variable model for the given data based on the constraints on the encoding process. Few more interesting applications of Auto-encoders are Image Coloring and Watermark removal from Images.</p><p>As we saw, Auto-encoders and Self Supervised Learning have huge potential not only concerning Computer Vision but also other subset fields of AI like Natural Language Processing. It has huge potential and is constantly improving in recent times.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/80/0*wcVMDJQw7kp9wSmu" /></figure><p>Tech enthusiast <a href="https://ptechnologyblog.wordpress.com/author/pranavraikote/">View all posts by Pranav Raikote</a></p><p><strong>Published</strong></p><p><em>Originally published at </em><a href="https://ptechnologyblog.wordpress.com/2020/05/24/self-supervised-learning-autoencoders/"><em>http://ptechnologyblog.wordpress.com</em></a><em> on May 24, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e34a378bd4fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>