<?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 Simeon Kostadinov on Medium]]></title>
        <description><![CDATA[Stories by Simeon Kostadinov on Medium]]></description>
        <link>https://medium.com/@simonnoff?source=rss-5cdfd010517e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kzjEEoONhU_l6s00masj9g.jpeg</url>
            <title>Stories by Simeon Kostadinov on Medium</title>
            <link>https://medium.com/@simonnoff?source=rss-5cdfd010517e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 18:52:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@simonnoff/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[What Is Deep Transfer Learning and Why Is It Becoming So Popular?]]></title>
            <link>https://medium.com/data-science/what-is-deep-transfer-learning-and-why-is-it-becoming-so-popular-91acdcc2717a?source=rss-5cdfd010517e------2</link>
            <guid isPermaLink="false">https://medium.com/p/91acdcc2717a</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[transfer-learning]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Simeon Kostadinov]]></dc:creator>
            <pubDate>Sat, 16 Nov 2019 17:51:44 GMT</pubDate>
            <atom:updated>2019-11-16T17:51:44.633Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pgOk5R30LWFLn81DQqzN-w.jpeg" /><figcaption>A man sitting on a bridge in Austria</figcaption></figure><h3>Introduction</h3><p>As we already know, large and effective deep learning models are data-hungry. They require training with thousands or even millions of data points before making a plausible prediction.</p><p>Training is very expensive, both in time and resources. For example, the popular language representation model BERT, developed by Google, has been trained on <strong>16 Cloud TPUs (64 TPU chips total) for 4 days</strong>. Put in perspective, this is ~60 desktop computers running non-stop for 4 days.</p><h3>Google AI on Twitter</h3><p>We have released @TensorFlow code+models for BERT, a brand new pre-training technique which is now state-of-the-art on a wide array of natural language tasks. It can also be used on many new tasks with minimal changes and quick training! https://t.co/rLR6U7uiPj</p><p>The biggest problem, though, is that models like this one are performed only on a single task. Future tasks require a new set of data points as well as equal or more amount of resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*V2uJIIsWsdhvuVBt" /><figcaption>Photo by <a href="https://unsplash.com/@noguidebook?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Rachel</a> on <a href="https://unsplash.com/s/photos/learning?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>However, the human brain does not work that way. It does not discard previously obtained knowledge when solving a new task. Instead, it makes decisions based on things learnt from the past.</p><p><em>Transfer learning aims to mimic this behaviour.</em></p><h3>What is transfer learning?</h3><p><em>Transfer learning is an approach in deep learning (and machine learning) where knowledge is transferred from one model to another.</em></p><blockquote>Def:<em> Model A is successfully trained to solve source task T.a using a large dataset D.a. However, the dataset D.b for a target task T.b is too small, preventing Model B from training efficiently. Thus, we use part of model A to predict results for task T.b.</em></blockquote><p>A common misconception is that training and testing data should come from the same source or be with the same distribution.</p><p>Using transfer learning, we are able to solve a particular task using full or part of an already pre-trained model on a different task.</p><p>The renowned AI leader, Andrew Ng, explains this concept very well in the video below.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FyofjFQddwHE&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DyofjFQddwHE&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FyofjFQddwHE%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/66c781045b540e2985bbb9bb9dceeb34/href">https://medium.com/media/66c781045b540e2985bbb9bb9dceeb34/href</a></iframe><h3>When to use transfer learning?</h3><p>Transfer learning is becoming the go-to way of working with deep learning models. The reasons are explained below.</p><h4>Lack of data</h4><p>Deep learning models require a LOT of data for solving a task effectively. However, it is not often the case that so much data is available. For example, a company may wish to build a very specific spam filter to its internal communication system but does not possess lots of labelled data.</p><p>In that case, a specific target task can be solved using a pre-trained model for a similar source task.</p><blockquote><strong>The tasks can be different but their domains should be the same.</strong></blockquote><p>In other words, you are unable to do transfer learning between speech recognition and image classification tasks since the input datasets are of different types.</p><p>What you can do is using a pre-trained image classifier on dog photos to predict cat photos.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KJu3jZwHxsCbc3RTfTBPkQ.gif" /><figcaption>Source: “How to build your own Neural Network from scratch in Python” by James Loy</figcaption></figure><h4>Speed</h4><p>Transfer learning cuts a large percentage of training time and allows for building various solutions instantly. In addition, it prevents from setting up a complex and costly Cloud GPU/TPU.</p><h4>Social good</h4><p>Using transfer learning positively impacts the environment.</p><p>According, to a study in the <a href="https://www.technologyreview.com/s/613630/training-a-single-ai-model-can-emit-as-much-carbon-as-five-cars-in-their-lifetimes/">MIT Technology Review</a>, a large neural network (200M+ parameters) trained on a Cloud TPU produces CO2 equivalent to ~6 cars during their lifetime. Transfer learning can prevent the extensive usage of these powerful processing units.</p><h3>Deep Transfer Learning Strategies</h3><p>Transfer learning can be applied through several different strategies both in the deep and machine learning space. In this article, I will cover deep learning only techniques called <em>Deep Transfer Learning Strategies</em>.</p><p>There are 3 main strategies for doing transfer learning on deep learning models.</p><h4>Direct use of pre-trained models</h4><p>The simplest strategy is to solve a target task by directly applying a model from a source task.</p><p>Such models are typically large (millions of parameters) neural networks, trained for days or even weeks on state-of-the-art machines.</p><p>Big corporations (companies, universities etc.) tend to release such models to the public, aiming to enhance the development of this field.</p><p>Some pre-trained models used directly include the aforementioned <a href="https://arxiv.org/abs/1810.04805">BERT</a> as well as <a href="https://pjreddie.com/darknet/yolo/">YOLO (You Only Look Once)</a>, <a href="https://nlp.stanford.edu/projects/glove/">GloVe</a>, <a href="https://github.com/facebookresearch/UnsupervisedMT">UnsupervisedMT</a> and more.</p><h4>Leveraging feature extraction from pre-trained models</h4><p>Instead of using the model end-to-end as in the previous example, we can treat the pre-trained neural network as a feature extractor by discarding the last <strong>fully-connected output layer</strong>.</p><p>This approach allows us to directly apply new dataset to solve an entirely different problem.</p><p>It brings 2 main advantages:</p><ul><li><strong>Allows for specifying the dimensions of the last fully-connected layer.</strong></li></ul><p>For example, the pre-trained network may have <em>7 x 7 x 512 </em>output from the layer prior to the last fully-connected. We can flatten this to <em>21,055 </em>which results in a new<em> N x 21,055 </em>network output (<em>N </em>— number of data points).</p><ul><li><strong>Allows for using a lightweight linear model (e.g. Linear SVM, Logistic Regression).</strong></li></ul><p>Since the pre-trained complex neural network model is used as features for the new task, we are allowed to train a simpler and faster linear model to modify the output based on the new dataset.</p><p><em>The feature extraction strategy is best suited for situations when the target task dataset is very small.</em></p><h4>Fine-tuning last layers of pre-trained models</h4><p>We can go one step further by not only training the output classifier but also fine-tune weights in some layers of the pre-trained model.</p><p>Typically, the earlier layers of the network (especially for CNN) are frozen, whereas the last ones are freed up for tuning.</p><p>This allows us to perform full training on the existing model and modify the parameters at the very last layers.</p><blockquote>We choose to modify only the last layers since it has been observed that earlier layers in a network capture more generic features while later ones are very dataset-specific.</blockquote><p>Let’s say our initial pre-trained model recognizes Mercedes cars with very high accuracy. The initial layers of this model tend to capture information about the position of wheels, the form of the car, curves etc. We can keep those when working on the next task of recognizing Ferrari cars. However, for the more specific Ferrari features, we should retrain the last layers with the new dataset.</p><p><em>Having said that, the fine-tuning strategy is best used when the target task dataset is significantly big as well as share a similar domain to the source one.</em></p><h3>Resources</h3><p>This article was inspired by a collection of papers and tutorials, some of which include:</p><ul><li><a href="http://cs231n.github.io/transfer-learning/">Transfer Learning</a> by Andrej Karpathy @ Stanford.</li><li><a href="https://towardsdatascience.com/a-comprehensive-hands-on-guide-to-transfer-learning-with-real-world-applications-in-deep-learning-212bf3b2f27a">A Comprehensive Hands-on Guide to Transfer Learning with Real-World Applications in Deep Learning</a> by <a href="https://towardsdatascience.com/@dipanzan.sarkar?source=post_page-----212bf3b2f27a----------------------">Dipanjan (DJ) Sarkar</a>.</li><li><a href="https://www.pyimagesearch.com/2019/05/27/keras-feature-extraction-on-large-datasets-with-deep-learning/">Keras: Feature extraction on large datasets with Deep Learning</a> by Adrian Rosebrock.</li><li><a href="https://www.pyimagesearch.com/2019/06/03/fine-tuning-with-keras-and-deep-learning/">Fine-tuning with Keras and Deep Learning</a> by Adrian Rosebrock.</li><li><a href="https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;arnumber=5288526">A Survey on Transfer Learning.</a></li><li><a href="https://machinelearningmastery.com/transfer-learning-for-deep-learning/">A Gentle Introduction to Transfer Learning for Deep Learning</a> by Jason Brownlee.</li><li><a href="https://machinelearningmastery.com/how-to-use-transfer-learning-when-developing-convolutional-neural-network-models/">Transfer Learning in Keras with Computer Vision Models</a> by Jason Brownlee.</li></ul><h3>Thank you for reading. Hope you enjoyed this article. ❤️</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91acdcc2717a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/what-is-deep-transfer-learning-and-why-is-it-becoming-so-popular-91acdcc2717a">What Is Deep Transfer Learning and Why Is It Becoming So Popular?</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[My Analysis from 50+ papers on the Application of ML in Credit Lending]]></title>
            <link>https://medium.com/data-science/my-analysis-from-50-papers-on-the-application-of-ml-in-credit-lending-b9b810a3f38?source=rss-5cdfd010517e------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9b810a3f38</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[fintech]]></category>
            <category><![CDATA[money]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Simeon Kostadinov]]></dc:creator>
            <pubDate>Mon, 21 Oct 2019 13:33:39 GMT</pubDate>
            <atom:updated>2019-10-21T13:33:39.524Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*XosDeIxqKyW8LyoI" /><figcaption>Photo by <a href="https://unsplash.com/@katiemoum?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Katie Moum</a> on <a href="https://unsplash.com/s/photos/government?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Credit-lending is more than 200 years old industry and is the banks’ primary responsibility. Throughout the years, it has been experiencing gradual improvements, but, with the rise of machine learning and big data, the whole process of lending money could radically change.</p><p>The use of powerful algorithms like gradient boosting and neural networks has shown great potential for improving the efficiency, speed and accuracy of tasks performed by credit analysts. Also, the rise of numerous data generation sources (e.g. social media, mobile and web activity) has opened possibilities for unique ways to underwrite loans.</p><p>However, unleashing the full potential of machine learning for credit lending still poses multiple challenges.</p><p>I have decided to explore this topic in details by covering more than 50 research papers and ~20 business reports. The source of my research varies from papers published in NIPS and ICML (two of the biggest ML conferences) to McKinsey&amp;Company reports. I have summarised my observations below.</p><h3>Impact of Machine Learning on Credit Risk Assessment</h3><p>Machine learning can benefit the credit lending industry in two ways: <em>improve operational efficiency</em> and <em>make use of new data sources for predicting credit score</em>.</p><h4>Improve Operational Efficiency</h4><p>In a recent <a href="https://www.youtube.com/watch?v=j2nGxw8sKYU&amp;t=515s">keynote</a>, Andrew Ng has wisely said:</p><blockquote>Automate tasks, not jobs.</blockquote><p>There exist tens of tasks involved in the process of determining creditworthiness (both corporate and consumer). Some of them can already be fully automated:</p><ul><li>Work with spreadsheets;</li><li>Documents analysis;</li><li>Phone calls;</li><li>Gathering data from customers and corporations;</li></ul><p>For instance, ICDAR is a conference entirely dedicated to research in the area of document analysis and recognition. The best performing algorithms in 2019 have achieved an accuracy of over 95%, which is very close to a human-like performance.</p><h4>Make Use of New Data Sources for Predicting Credit Score</h4><p>The potential of ML algorithms is further unleashed when they are applied to data coming from alternative and unconventional sources. Based on underlying patterns in those thousands of data points, these algorithms can predict one’s credit score.</p><p>Two fundamental conditions allow for the above to be practically applied:</p><ol><li>In today’s world, humans generate an enormous amount of data, both online and offline (through their various devices).</li><li>The current ways of determining creditworthiness rely predominantly on the consumer’s credit history. However, many people from developing countries (China, India and Africa) have been underbanked their whole lives. But, most of them generate valuable data every day through their smartphone devices.</li></ol><p>The startup <a href="https://branch.co/">Branch</a> has tapped into this opportunity by introducing a loan system for people in developing countries which relies on mobile data like SMS logs, contact lists, GPS etc.</p><p><em>The second application of ML on the credit-lending industry will be the main focus of this article.</em></p><h3>The Most Effective ML Algorithms</h3><p>During my research, I came across a variety of algorithms used in different and unique ways. However, the best-performing ones are not necessarily the latest invented or most complex. Two of the reports I found have managed to compare the best performing models critically.</p><p>The first report from 2018 compares six algorithms (3 of which are deep learning-based) to show that the deep learning-based algorithms do not perform any better than the rest. The conclusion is that a gradient boosting algorithm is most suitable for determining creditworthiness.</p><p>On the other hand, another report from 2019 states that “advanced methods were found to perform extremely well on credit scoring data sets such as artificial neural networks”. A study was made on over 40 research papers, dated after 2009.</p><h4>Bottom Line</h4><p>The best performing classification algorithms on the credit scoring problem vary based on the specific dataset, features selection and more. However, the following tend to be preferred more than anything else:</p><ul><li>Support Vector Machines (SVM);</li><li>Gradient Boosting;</li><li>Tree-based algorithms (e.g. Random Forest);</li><li>Deep Neural Networks (DNN);</li></ul><p>Interestingly, DNNs do not yield significantly better results which make us doubt their use. Due to regulatory constraints (see the section below), neural networks might turn out more challenging to put into practice compared to other ML algorithms.</p><h3>Challenges to Industry Adoption</h3><p>The main limitations of applying an ML algorithm to determine credit score are not related to the algorithm’s poor performance or lack of sophistication. Instead, the most significant hurdles are associated with everything outside of building this algorithm/model.</p><ul><li><strong>Biased data</strong> — all supervised ML algorithms assume that the future would follow similar patterns as the past. The result in that models can make predictions based on underlying human characteristics unrelated to one’s ability to repay a loan, also called “bias against groups or classes of people”. Banks are looking for ways to battle this challenge through methods like “demographic blindness” (select uncorrelated set of features), “equal odds” (choose an equal number of true-positive and false-positive for each class) and more.</li><li><strong>Interpretability</strong> — machine learning algorithms are considered “black-box” due to the inability to understand the reasoning behind individual decisions. In 1974 Congress enacted “The Equal Credit Opportunity Act (ECOA)” which prohibits creditors from making decisions based on sensitive characteristics. Treating a model as a “black-box” does not comply with those regulations and may prevent quality and powerful algorithms from ever being used in practice.</li><li><strong>Regulations</strong> — in addition to ECOA, Congress has passed “The Fair Credit Reporting Act (FCRA)” which aims to maintain fairness in credit reporting and ensure consumer’s privacy by protecting or using certain information. However, it is considered very unlikely that deep learning algorithms which require thousands of data points comply with FCRA. Creditors which rely on big data to make decisions often circumvent these regulations by denying to reveal any model’s specifications, stating they are a “trade secret”. This is not a sustainable solution, and both businesses and researchers are exploring alternative options.</li><li><strong>Scalability</strong> — once a model is proven to perform well and does not interfere with any regulatory requirements, the challenge of scaling it up needs to be overcome. Reducing training time, integrating the model into existing products and supplying a constant stream of data are just some of the problems every organisation faces before experiencing the full potential of ML.</li></ul><h3>Resources</h3><ul><li><a href="https://arxiv.org/abs/1811.11079">Robust Classification of Financial Risk</a>;</li><li><a href="https://arxiv.org/abs/1811.07698">Towards Global Explanation of Credit Scoring</a>;</li><li><a href="https://arxiv.org/abs/1811.05245">Interpretable Credit Application with Counterfactual explanations</a>;</li><li><a href="https://arxiv.org/abs/1906.10244">Generating User-friendly for Loan Denials using GANs</a>;</li><li><a href="https://arxiv.org/abs/1811.12615">An Interpretable Model with Globally Consistent Explanations for Credit Risk</a>;</li><li><a href="https://www.matec-conferences.org/articles/matecconf/abs/2016/17/matecconf_mimt2016_05004/matecconf_mimt2016_05004.html">Credit Scoring with Feature Selection Approach Based on Deep Learning</a>;</li><li><a href="https://arxiv.org/pdf/1607.02470.pdf">Deep Learning for Morgage Risk</a>;</li><li><a href="https://journals.plos.org/plosone/article/file?id=10.1371/journal.pone.0180944&amp;type=printable">A Deep Learning Framework for Financial Time Series Using Stacked Autoencoders and Long-Short Term Memory.</a></li><li><a href="https://pdfs.semanticscholar.org/e4dd/fdd95aafb0042abf6c839d8a688cdf07c780.pdf">A Credit Scoring Model Based on Alternative Mobile Data for Financial Inclusion</a>;</li><li><a href="https://res.mdpi.com/risks/risks-07-00029/article_deploy/risks-07-00029-v2.pdf?filename=&amp;attachment=1">[Report] Machine Learning in Banking Risk Management</a>;</li><li><a href="https://www.mdpi.com/2227-9091/6/2/38">[Report] Credit Risk Analysis Using Machine and Deep Learning Models</a>;</li><li><a href="https://www.imf.org/en/Publications/WP/Issues/2019/05/17/FinTech-in-Financial-Inclusion-Machine-Learning-Applications-in-Assessing-Credit-Risk-46883">[Report] FinTech in Financial Inclusion Machine Learning Applications in Assessing Credit Risk</a>;</li><li><a href="https://digitalcommons.law.yale.edu/cgi/viewcontent.cgi?article=1122&amp;context=yjolt">[Report] Credit Scoring in the Era of Big Data</a>;</li><li><a href="https://www.bis.org/review/r181114g.pdf">[Report] What Are We Learning About Artificial Intelligence in Financial Industries?</a>;</li><li><a href="https://www.mckinsey.com/business-functions/risk/our-insights/derisking-machine-learning-and-artificial-intelligence">[McKinsey&amp;Company Report] Derisking Machine Learning and Artifical Intelligence</a>;</li><li><a href="https://www.mckinsey.com/business-functions/mckinsey-analytics/our-insights/what-ai-can-and-cant-do-yet-for-your-business">[McKinsey&amp;Company Report] What AI can and can’t do (yet) for your business</a>;</li><li><a href="https://www.mckinsey.com/industries/financial-services/our-insights/banking-matters/scanning-the-fintech-landscape">[McKinsey&amp;Company Report] Scanning the Fintech Landscape: 10 Disruptive Models</a>;</li><li>+ many more.</li></ul><h3>Thank you for reading. Hope you enjoyed this article. ❤️</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9b810a3f38" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/my-analysis-from-50-papers-on-the-application-of-ml-in-credit-lending-b9b810a3f38">My Analysis from 50+ papers on the Application of ML in Credit Lending</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[NIPS 2018 paper on “Robust Classification of Financial Risk” — Summary]]></title>
            <link>https://medium.com/data-science/nips-2018-paper-on-robust-classification-of-financial-risk-summary-93445019d4f0?source=rss-5cdfd010517e------2</link>
            <guid isPermaLink="false">https://medium.com/p/93445019d4f0</guid>
            <category><![CDATA[research]]></category>
            <category><![CDATA[paper]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Simeon Kostadinov]]></dc:creator>
            <pubDate>Sun, 18 Aug 2019 00:41:55 GMT</pubDate>
            <atom:updated>2019-08-18T00:41:55.112Z</atom:updated>
            <content:encoded><![CDATA[<h3>NIPS 2018 paper on “Robust Classification of Financial Risk” — Summary</h3><p>In this short article, I would like to give an overview of a research paper called <a href="https://arxiv.org/abs/1811.11079">“Robust Classification of Financial Risk”</a>. The paper was accepted for <a href="https://nips.cc/Conferences/2018">NIPS 2018 </a>Workshop on <em>“Challenges and Opportunities for AI in Financial Services” </em>and aims to solve very interesting and unique problem occurring in credit lending done with deep learning models.</p><h3>Overview</h3><h4>Authors</h4><p>The paper was written by 4 computer sciences from Harvard University.</p><h4>Published</h4><p>The <a href="https://arxiv.org/abs/1811.11079">paper</a> was published on 27 Nov 2018 and is part of NIPS 2018 Workshop on <em>“Challenges and Opportunities for AI in Financial Services”</em>.</p><h4>Problem</h4><p>It has been observed that small changes in the input data can substantially change the outcome of a machine learning model. This presents challenges when trying to deploy such models in real-world systems, especially in financial services, because it allows for carefully constructed input to “fool” the model into making wrong decisions.</p><h4>Solution</h4><p>The authors aim to solve the problem using a <em>“robust optimization algorithm” </em>which enhances a neural network model to focus on the changes (perturbations) which yield higher classification losses.</p><h4>Results</h4><p>The evaluation was made by comparing accuracy and loss between 2 neural networks. Both models use the same underlying structure (4 layers with same number of units and activations per layer) but one also uses the <em>“robust optimization algorithm”</em>. The results are directly taken from the paper:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IfsWVwU1XXtmNCwWYmuq7w.png" /><figcaption>Credits to the authors of “Robust Classification of Financial Risk”</figcaption></figure><p>As you can see the loss has dropped from 1.0 to 0.6 and the accuracy was improved from 50% to 70%.</p><h4>Paper walkthrough</h4><p>The research aims to answer those 2 questions:</p><ol><li><em>Do small perturbations to input data lead to misclassification?</em></li><li><em>Can robust classification help machine learning models used in financial services perform better on perturbed examples?</em></li></ol><p>The analysis was performed on a <a href="https://www.lendingclub.com/info/download-data.action">dataset including lending data of 421,095 applications obtained from LendingClub</a> (a peer-to-peer lending platform). The authors are using 4 types of perturbations (changes in input data) including:</p><ul><li><em>Fast Gradient Sign Method (FGSM)</em> — perturbs the input in the direction of the gradient of the loss function with respect to that input. In other words, this method applies the <a href="https://en.wikipedia.org/wiki/Sign_function"><em>sign</em></a> function to the gradient to determine in which direction (positive, negative or zero) the input should change. The size of each change is determined by a constant <em>e</em>. For more details, see <em>Section 2.2</em> in the paper and go through this <a href="https://www.tensorflow.org/beta/tutorials/generative/adversarial_fgsm">great TensorFlow tutorial.</a></li><li><em>Projected Gradient Descent </em>— the same as FGSM but uses the actual gradient as opposed to its <em>sign</em> value.</li><li><em>Jacobian-based Saliency Mapping Attack </em>— perturbs the inputs with highest impact on the loss function.</li><li><em>Max Salience Attack</em> — perturbs each feature individually by a set percent increase or decrease, and finds which of these features produces the highest rate of successful misclassifications. After that, the authors take one and two of these most affected features and perturb them by a fixed percent change.</li></ul><p><em>Note: “perturbation” is a change in the input which might be minor or unnoticeable for a human but actually makes the network misclassify with a huge error.</em></p><p>Coming back to question 1, the authors state that:</p><blockquote>We first show that that small perturbations on our high-accuracy loan grade prediction model are successful, with average perturbation of 1.3% per feature leading to misclassification on 95% of inputs.</blockquote><p>The model is a neural network with 2 dense <em>ReLU</em> layers of size 100 and 60, using a dropout of 0.2 and final <em>softmax</em> layer with 7 possible outcomes. The number of outcomes is determined based on the data — LendingClub uses a credit system by assigning a score of A-G to any candidate.</p><p>For the second question, the authors use a <strong>“<em>robust optimization algorithm” </em>which enhances the network by identifying which perturbations have high classification losses, and focusing more on those perturbation types during the training.</strong></p><p>The results you saw above are obtained after training both the neural network and the network with <em>“robust optimization algorithm”</em> over a training set with fixed uniform distribution over perturbation types at each iterations.</p><p><em>In other words, at every training step the authors uniformly random pick a dataset where one of the four perturbation types is applied.</em></p><p>As you can see the proposed optimization algorithm has a significant effect. For more details on how this algorithm works, read <em>Section 2.3</em> from the paper.</p><h3>Key Takeaways</h3><p>Below are listed some useful points found in the paper:</p><ul><li>Deep learning models are susceptible to attacks using adversarial inputs. One such example is credit risk assessment where robustness against such attacks is essential.</li><li>Algorithms, similar to the one applied in this paper, can enhance existing models to allow for identifying such misclassifications.</li><li>Useful resource is the <a href="https://www.lendingclub.com/info/download-data.action">LendingClub dataset</a> which includes lending data for thousands of candidates.</li></ul><h3>Thank you for the reading. Hope you enjoyed the article 🤩 and I wish you a great day!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93445019d4f0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/nips-2018-paper-on-robust-classification-of-financial-risk-summary-93445019d4f0">NIPS 2018 paper on “Robust Classification of Financial Risk” — Summary</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[Effective Way for Finding Deep Learning Papers]]></title>
            <link>https://medium.com/data-science/effective-way-for-finding-deep-learning-papers-daa27415ad16?source=rss-5cdfd010517e------2</link>
            <guid isPermaLink="false">https://medium.com/p/daa27415ad16</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[research]]></category>
            <category><![CDATA[reading]]></category>
            <dc:creator><![CDATA[Simeon Kostadinov]]></dc:creator>
            <pubDate>Tue, 13 Aug 2019 09:07:24 GMT</pubDate>
            <atom:updated>2019-08-13T09:07:24.343Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CwhpCy8yXHoNQwWxpTSCbg.jpeg" /><figcaption>Woman holding book on bookshelves — Photo by Becca Tapert on Unsplash</figcaption></figure><p>Recently, I came across a <a href="https://www.youtube.com/watch?v=733m6qBH-jI">great video of Prof. Andrew Ng</a> who explains in front of a CS class at Stanford how one can excel in the field of artificial intelligence.</p><p>I will rephrase his words below.</p><blockquote>Deep learning is evolving fast enough that, even though you have learned the foundations of deep learning, when you are working on specific applications you need to read research papers to stay on top of most recent ideas.</blockquote><p>Prof. Ng shares a simple and quite effective technique for planning your reading. It includes the following steps:</p><ul><li><em>Pick a topic of your interest (e.g. speech recognition, text summarization, image generation with GANs).</em></li><li><em>Compile a list of 10–20 papers/articles/blog posts.</em></li><li><em>Gradually expand this list to 50+ papers.</em></li></ul><p>In addition, he proposed several places to look for resources including <a href="https://twitter.com/search?q=%23ArtificialIntelligence">Twitter</a>, <a href="https://www.reddit.com/r/MachineLearning/">Machine Learning subreddit</a>, <a href="https://nips.cc/">NIPS</a>, <a href="https://icml.cc/">ICML</a> and <a href="https://iclr.cc/">ICLR</a> (the last 3 are machine learning conferences).</p><p>Following this technique, a question came to my mind:</p><blockquote>How much time and effort does it take to find the RIGHT collection of papers?</blockquote><p>After dedicating several hours and finally succeeding in finding a set of papers and articles of my desire, I decided to share my experience and help others in this journey.</p><h4>How to Begin?</h4><p>The very first step is to <strong>decide on a specific topic/problem</strong>. In my case, I was interested in learning more about how deep learning can be applied to credit risk assessment for any type of loan (mortgage, personal loan, credit card etc.)</p><p>Once you have the topic, it is good to <strong>list down all keywords</strong> related to it. For me these were: <em>credit, loan, lending, mortgages, risk, assessment, score, banking, finance.</em></p><p>When you are searching for a paper/article/blog post combine those keywords with “deep learning”, “machine learning” or “neural networks” to get needed results.</p><h4>Explore the Web for Resources</h4><p>Finding the right resources may take from 1 hour to 1–2 days. It really depends on how much determined you are to find the “perfect” set of papers. However, one should avoid spending unnecessary time on research and, as long as he/she finds 3–4 papers, the actual reading can begin. Below are listed several effective ways for finding resources.</p><ul><li><strong>Standard Google search</strong></li></ul><p>It is obvious to anyone that a Google search with the above keywords is the first step. Unfortunately, I haven’t found this approach so effective since often the results do not include actual solutions but rather overview of the topic, adaptable to any reader.</p><p>However, if you search <a href="https://scholar.google.com/">Google Scholar</a> the likelihood of finding what you need is much higher.</p><ul><li><strong>Explore the top machine learning conferences</strong></li></ul><p>The second step is to skim through all headlines from past years’ conferences and extract what sounds intriguing. For example, let’s look at the <a href="https://nips.cc/Conferences/2019">NIPS Conference</a> and try to find the list of presented papers.</p><ul><li>First, go to <a href="https://nips.cc/">https://nips.cc/</a> and change the year from 2019 to 2018, 2017 etc.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rK-TlaZka2g5hkgV1o-9wg.png" /></figure><ul><li>For every year, change the URL from <a href="https://nips.cc/Conferences/2019">https://nips.cc/Conferences/2019</a> to <a href="https://nips.cc/Conferences/2019/Workshopbook">https://nips.cc/Conferences/2019/Workshopbook</a> and hit Enter. The “Workshop book” PDF with summary of all papers for this year will begin downloading automatically.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*ObkTFD_-77PFcSUcI_7T7Q.png" /></figure><ul><li>Finally, look through the sections and pick the papers which are related to your topic.</li></ul><p>The website of the other conferences also store “Workshop books” which you can obtain in a similar way.</p><ul><li><strong>Search through most popular online research papers libraries</strong></li></ul><p>The list of such websites include <a href="https://arxiv.org/">arxiv.org</a>, <a href="https://www.semanticscholar.org/">Semantic Scholar</a>, <a href="https://www.sciencedirect.com/">Science Direct</a> and others. Use your predefined keywords together with the “Advanced Search” option on each platform to find interesting material.</p><p><em>NB: some papers may be private and require purchasing. Keep in mind that if you are a student (from any university) you are allowed to access those papers for FREE. You might be able to log in with your student credentials and obtain the PDFs. Otherwise, speak to your school for further instructions.</em></p><h4>Dive Deep into a Paper</h4><p>The process of finding a set of papers which perfectly match your topic may be tedious and time consuming. You will most likely find related papers (in the same or adjacent fields) but not exactly what you need.</p><p><em>Don’t forget that researchers produce their work based on previous findings and every paper includes a ton of references.</em></p><p>Here is how I utilized the above statement to find what I wanted:</p><ol><li>After looking at the NIPS 2018 Workshop book, I found a great workshop called <em>“Challenges and Opportunities for AI in Financial Services: the Impact of Fairness, Explainability, Accuracy, and Privacy”.</em></li><li>Most of the papers weren’t exactly about assessing credit worthiness but instead about new ways of making deep learning models, used in the financial sector, more explainable.</li><li>I thought that in order for the authors to discuss a model’s explainability, they must have looked (and cited) the actual algorithm. Surprisingly, I found the very first 3–4 references to be exactly what I needed.</li></ol><p>This approach helped me expand my list of resources and find the truly useful material.</p><h4>Filter the Noise</h4><p>In this final section, I want to go over several things I look at when choosing a specific paper. This helps me filter much of the noise and let me focus on fewer but higher quality sources.</p><ul><li><em>Authors </em>— papers can be published by various researchers, specialized in different areas. I typically look up the authors’ names and institution on LinkedIn or Twitter. For example, a paper on credit risk assessment with deep learning written by researchers from a large bank/financial institution is a good sight for a quality material. In addition, good schools (Stanford, MIT, Université de Montréal) and companies (Facebook, Google, Baidu) typically have the strongest researchers.</li><li><em>Date of publishing</em> — the field of deep learning is advancing rapidly, so a paper from 5 years ago might be irrelevant today. I tend to look for more recent material but never neglect a good paper from long time ago, especially if it introduces a breakthrough technique.</li><li><em>Number of cites </em>— if a paper hasn’t been cited that often this does not automatically mean it is not a quality material. I often look at the number of cites just to get a sense of the paper’s popularity but this is never the deciding factor.</li></ul><p>This concludes my approach of effectively searching for research papers and articles. If you have any comments or suggestions, please don’t hesitate to share them in the comment section.</p><h3>Thank you for the reading. Hope you enjoyed the article 🤩 and I wish you a great day!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=daa27415ad16" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/effective-way-for-finding-deep-learning-papers-daa27415ad16">Effective Way for Finding Deep Learning Papers</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[Understanding Backpropagation Algorithm]]></title>
            <link>https://medium.com/data-science/understanding-backpropagation-algorithm-7bb3aa2f95fd?source=rss-5cdfd010517e------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bb3aa2f95fd</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Simeon Kostadinov]]></dc:creator>
            <pubDate>Thu, 08 Aug 2019 12:17:15 GMT</pubDate>
            <atom:updated>2019-08-12T23:47:35.648Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn the nuts and bolts of a neural network’s most important ingredient</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aX5vbutqsmLpuMvY4ltDow.jpeg" /><figcaption>“A man is running on a highway” — photo by <a href="https://unsplash.com/@whatyouhide?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Andrea Leopardi</a> on <a href="https://unsplash.com/search/photos/running?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p><strong>Backpropagation algorithm</strong> is probably the most fundamental building block in a neural network. It was first introduced in 1960s and almost 30 years later (1989) popularized by Rumelhart, Hinton and Williams in a paper called <em>“</em><a href="https://www.nature.com/articles/323533a0"><em>Learning representations by back-propagating errors</em></a><em>”</em>.</p><p><strong>The algorithm is used to effectively train a neural network through a method called chain rule.</strong> In simple terms, after each forward pass through a network, backpropagation performs a backward pass while adjusting the model’s parameters (weights and biases).</p><p>In this article, I would like to go over the mathematical process of training and optimizing a simple 4-layer neural network. <em>I believe this would help the reader understand how backpropagation works as well as realize its importance.</em></p><h3>Define the neural network model</h3><p>The 4-layer neural network consists of 4 neurons for the <strong>input layer</strong>, 4 neurons for the <strong>hidden layers</strong> and 1 neuron for the <strong>output layer</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sSIeU-WhsuHCQlOA00IBXg.jpeg" /><figcaption>Simple 4-layer neural network illustration</figcaption></figure><h4>Input layer</h4><p>The neurons, colored in <strong>purple</strong>, represent the input data. These can be as simple as scalars or more complex like vectors or multidimensional matrices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*JVKKlpPpmnes2CQoQ3uAbw.png" /><figcaption>Equation for input x_i</figcaption></figure><p>The first set of activations (<em>a</em>) are equal to the input values. <em>NB: “activation” is the neuron’s value after applying an activation function. See below.</em></p><h4>Hidden layers</h4><p>The final values at the hidden neurons, colored in <strong>green</strong>,<strong> </strong>are computed using <em>z^l</em> — weighted inputs in layer <em>l</em>, and <em>a^l</em>— activations in layer <em>l</em>. For layer 2 and 3 the equations are:</p><ul><li><em>l = 2</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*38G8wzETqpzwQvtExO6k3w.png" /><figcaption>Equations for z² and a²</figcaption></figure><ul><li><em>l = 3</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*pmnSATBMHgCnTSiL_cCy9Q.png" /><figcaption>Equations for z³ and a³</figcaption></figure><p><em>W²</em> and <em>W³ </em>are the weights in layer 2 and 3 while b² and b³ are the biases in those layers.</p><p>Activations <em>a²</em> and <em>a³</em> are computed using an activation function <em>f</em>. Typically, this <strong>function <em>f</em> is non-linear</strong> (e.g. <a href="https://en.wikipedia.org/wiki/Sigmoid_function">sigmoid</a>, <a href="https://en.wikipedia.org/wiki/Rectifier_(neural_networks)">ReLU</a>, <a href="https://en.wikipedia.org/wiki/Hyperbolic_function">tanh</a>) and allows the network to learn complex patterns in data. We won’t go over the details of how activation functions work, but, if interested, I strongly recommend reading <a href="https://medium.com/the-theory-of-everything/understanding-activation-functions-in-neural-networks-9491262884e0">this great article</a>.</p><p>Looking carefully, you can see that all of <em>x, z², a², z³, a³, W¹, W², b¹ </em>and<em> b²</em> are missing their subscripts presented in the 4-layer network illustration above. <strong>The reason is that we have combined all parameter values in matrices, grouped by layers. </strong>This is the standard way of working with neural networks and one should be comfortable with the calculations. However, I will go over the equations to clear out any confusion.</p><p>Let’s pick layer 2 and its parameters as an example. The same operations can be applied to any layer in the network.</p><ul><li><em>W¹</em> is a weight matrix of shape <em>(n, m)</em> where <em>n</em> is the number of output neurons (neurons in the next layer) and <em>m</em> is the number of input neurons (neurons in the previous layer). For us, <em>n = 2</em> and <em>m = 4</em>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*yRlAdSEUTPeteVQ6xFT8xg.png" /><figcaption>Equation for W¹</figcaption></figure><p><strong>NB: The first number in any weight’s subscript matches the index of the neuron in the next layer </strong>(in our case this is the <em>Hidden_2 layer</em>)<strong> and the second number matches the index of the neuron in previous layer </strong>(in our case this is the <em>Input layer</em>).</p><ul><li><em>x</em> is the input vector of shape <em>(m, 1)</em> where <em>m</em> is the number of input neurons. For us, <em>m = 4</em>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/144/1*VQav2v1g6qkRXD48-HlmpQ.png" /><figcaption>Equation for x</figcaption></figure><ul><li><em>b¹</em> is a bias vector of shape <em>(n , 1)</em> where <em>n</em> is the number of neurons in the current layer. For us, <em>n = 2</em>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/188/1*S4fXnuMxU0BTPZ_W78hAaQ.png" /><figcaption>Equation for b¹</figcaption></figure><p>Following the equation for <em>z², </em>we can use the above definitions of <em>W¹, x </em>and<em> b¹ </em>to derive “<em>Equation for z²”</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*rYAiLFIXevABB60bMZuFOQ.png" /><figcaption><em>Equation for z²</em></figcaption></figure><p>Now carefully observe the neural network illustration from above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*02zF6C6PYzGBbiah4-5fTQ.jpeg" /><figcaption>Input and Hidden_1 layers</figcaption></figure><p>You will see that <em>z²</em> can be expressed using (<em>z_1)²</em> and (<em>z_2)² </em>where (<em>z_1)²</em> and (<em>z_2)²</em> are the sums of the multiplication between every input <em>x_i</em> with the corresponding weight (<em>W_ij)¹.</em></p><p>This leads to the same “<em>Equation for z²” </em>and proofs that the matrix representations for <em>z², a², z³</em> and <em>a³</em> are correct.</p><h4>Output layer</h4><p>The final part of a neural network is the output layer which produces the predicated value. In our simple example, it is presented as a single neuron, colored in <strong>blue </strong>and<strong> </strong>evaluated as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/170/1*D1vfLBOaZSKCuBaOp8gK7Q.png" /><figcaption>Equation for output s</figcaption></figure><p>Again, we are using the matrix representation to simplify the equation. One can use the above techniques to understand the underlying logic. <strong>Please leave any comments below if you find yourself lost in the equations — I would love to help!</strong></p><h3>Forward propagation and evaluation</h3><p>The equations above form network’s forward propagation. Here is a short overview:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*51X_xj8p-jO8-plMfsyajg.png" /><figcaption>Overview of forward propagation equations colored by layer</figcaption></figure><p>The final step in a forward pass is to evaluate the <strong>predicted output <em>s</em></strong><em> </em>against an <strong>expected output <em>y</em></strong>.</p><p>The output <em>y </em>is part of the training dataset <em>(x, y) </em>where<em> x </em>is the input (as we saw in the previous section).</p><p>Evaluation between <em>s</em> and <em>y </em>happens through a <strong>cost function</strong>. This can be as simple as <a href="https://en.wikipedia.org/wiki/Mean_squared_error">MSE</a> (mean squared error) or more complex like <a href="http://neuralnetworksanddeeplearning.com/chap3.html">cross-entropy</a>.</p><p>We name this cost function <em>C</em> and denote it as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*f8CwUGDguGaqCh-qvtW7lA.png" /><figcaption>Equation for cost function C</figcaption></figure><p>were <em>cost </em>can be equal to MSE, cross-entropy or <a href="https://stats.stackexchange.com/questions/154879/a-list-of-cost-functions-used-in-neural-networks-alongside-applications">any other cost function</a>.</p><p>Based on <em>C</em>’s value, the model “knows” how much to adjust its parameters in order to get closer to the expected output <em>y</em>. This happens using the backpropagation algorithm.</p><h3>Backpropagation and computing gradients</h3><p>According to the paper from 1989, backpropagation:</p><blockquote>repeatedly adjusts the weights of the connections in the network so as to minimize a measure of the difference between the actual output vector of the net and the desired output vector.</blockquote><p>and</p><blockquote>the ability to create useful new features distinguishes back-propagation from earlier, simpler methods…</blockquote><p>In other words, <strong>backpropagation aims to minimize the cost function by adjusting network’s weights and biases.</strong> The level of adjustment is determined by the gradients of the cost function with respect to those parameters.</p><p>One question may arise — <strong>why computing gradients</strong>?</p><p>To answer this, we first need to revisit some calculus terminology:</p><ul><li><em>Gradient of a function C(x_1, x_2, …, x_m) in point x is a vector of the </em><a href="https://en.wikipedia.org/wiki/Partial_derivative"><em>partial derivatives</em></a><em> of C in x.</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*o1TgzZMHMWBUDamAtjKs2w.png" /><figcaption>Equation for derivative of C in x</figcaption></figure><ul><li><a href="https://en.wikipedia.org/wiki/Derivative"><em>The derivative of a function C measures the sensitivity to change of the function value (output value) with respect to a change in its argument x (input value)</em></a><em>. In other words, the derivative tells us the direction C is going.</em></li><li><em>The gradient shows how much the parameter x needs to change (in positive or negative direction) to minimize C.</em></li></ul><p>Compute those gradients happens using a technique called <a href="https://en.wikipedia.org/wiki/Chain_rule">chain rule</a>.</p><p>For a single weight <em>(w_jk)^l, </em>the gradient is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*RiYDrF5DgmbNubMq9x_czA.png" /><figcaption>Equations for derivative of C in a single weight <em>(w_jk)^l</em></figcaption></figure><p>Similar set of equations can be applied to <em>(b_j)^l</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*Xpco_RAhSlM9z5q6VSdy6Q.png" /><figcaption>Equations for derivative of C in a single bias <em>(b_j)^l</em></figcaption></figure><p>The common part in both equations is often called <em>“local gradient” </em>and is expressed as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*WQz6hHI1ymFlVCYwtIBdaQ.png" /><figcaption>Equation for local gradient</figcaption></figure><p>The <em>“local gradient” </em>can easily be determined using the chain rule. I won’t go over the process now but if you have any questions, please comment below.</p><p>The gradients allow us to optimize the model’s parameters:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*I_qw7AQwKvwfLuOHc7e4fg.png" /><figcaption>Algorithm for optimizing weights and biases (also called “Gradient descent”)</figcaption></figure><ul><li>Initial values of <em>w</em> and <em>b</em> are randomly chosen.</li><li>Epsilon (<em>e</em>) is the <a href="https://machinelearningmastery.com/understand-the-dynamics-of-learning-rate-on-deep-learning-neural-networks/">learning rate</a>. It determines the gradient’s influence.</li><li><em>w</em> and <em>b </em>are matrix representations of the weights and biases. Derivative of <em>C</em> in <em>w</em> or <em>b</em> can be calculated using partial derivatives of <em>C</em> in the individual weights or biases.</li><li>Termination condition is met once the cost function is minimized.</li></ul><p>I would like to dedicate the final part of this section to a simple example in which we will calculate the gradient of <em>C</em> with respect to a single weight <em>(w_22)²</em>.</p><p>Let’s zoom in on the bottom part of the above neural network:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CxdjKFrE-Vww0KmI-3Z5sA.png" /><figcaption>Visual representation of backpropagation in a neural network</figcaption></figure><p>Weight <em>(w_22)² </em>connects<em> (a_2)² </em>and<em> (z_2)²</em>, so computing the gradient requires applying the chain rule through <em>(z_2)³</em> and <em>(a_2)³:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*65rk0JpGEi6q0n2t6C688Q.png" /><figcaption>Equation for derivative of C in <em>(w_22)²</em></figcaption></figure><p>Calculating the final value of derivative of <em>C</em> in <em>(a_2)³</em> requires knowledge of the function <em>C</em>. Since <em>C</em> is dependent on <em>(a_2)³</em>, calculating the derivative should be fairly straightforward.</p><p>I hope this example manages to throw some light on the mathematics behind computing gradients. To further enhance your skills, I strongly recommend watching <a href="https://www.youtube.com/watch?v=isPiE-DBagM&amp;list=PL3FW7Lu3i5Jsnh1rnUwq_TcylNr7EkRe6">Stanford’s NLP series where Richard Socher gives 4 great explanations of backpropagation</a>.</p><h3>Final remarks</h3><p>In this article, I went through a detailed explanation of how backpropagation works under the hood using mathematical techniques like computing gradients, chain rule etc. <em>Knowing the nuts and bolts of this algorithm will fortify your neural networks knowledge and make you feel comfortable to take on more complex models. Enjoy your deep learning journey!</em></p><h3>Thank you for the reading. Hope you enjoyed the article 🤩 and I wish you a great day!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7bb3aa2f95fd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/understanding-backpropagation-algorithm-7bb3aa2f95fd">Understanding Backpropagation Algorithm</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[The Future of Lending Money Is Deep Learning]]></title>
            <link>https://medium.com/data-science/the-future-of-lending-money-is-deep-learning-61a9e21cf179?source=rss-5cdfd010517e------2</link>
            <guid isPermaLink="false">https://medium.com/p/61a9e21cf179</guid>
            <category><![CDATA[money]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[banking]]></category>
            <category><![CDATA[financial-services]]></category>
            <category><![CDATA[fintech]]></category>
            <dc:creator><![CDATA[Simeon Kostadinov]]></dc:creator>
            <pubDate>Tue, 30 Jul 2019 08:27:07 GMT</pubDate>
            <atom:updated>2019-07-30T14:50:20.120Z</atom:updated>
            <content:encoded><![CDATA[<h4>Deep learning is becoming the standard way of assessing credit risk and soon will surpass human decision-making.</h4><figure><img alt="Person holding 2 coins" src="https://cdn-images-1.medium.com/max/1024/1*P18P89B9lTpgkF86_p0nHw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@yakimadesign?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Jordan Rowland</a> on <a href="https://unsplash.com/search/photos/money?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>According to <a href="https://en.wikipedia.org/wiki/Bank">Wikipedia</a>, a bank is a <em>“financial institution that accepts deposits from the public and creates credit”</em> which means that one of the two main responsibilities of a bank is to <strong>lend money to commercial and corporate clients</strong>.</p><p>The process of issuing credit has increased in complexity over the years due to the different possibilities, market demands and clients’ circumstances. This makes the bank a highly regulated entity which is expected to act responsively when giving a loan. Together with the ever increasing user demand for speed and personalization, <strong>banks and all credit issuers are turning to the power of machine learning algorithms</strong>.</p><p>It is not a surprise to anyone that AI is picking up momentum and won’t be too long until it is integrated into any industry (from agriculture to aerospace engineering). The financial industry is not an exception as many startups are already exploring more efficient alternatives to established financial services (e.g. lending money). In response to this new wave of innovation, some incumbent companies are also jumping into the race.</p><p>In this article, we will go over the process of assessing credit worthiness and how AI enhances or even surpasses the existing techniques.</p><h3>Standard Practices for Assessing Credit Worthiness</h3><figure><img alt="Old machine from the 1900’s used by cashiers to give back change." src="https://cdn-images-1.medium.com/max/1024/1*OG8vLhvBaYUbwZXl6Z0M3g.jpeg" /></figure><p>In order to fully grasp the benefits that AI can bring to credit risk assessment, one should first understand the challenges presented with the standard practices.</p><p>In most cases, lenders turn to established methods for determining creditworthiness. These are based on the <a href="https://www.investopedia.com/terms/f/five-c-credit.asp">Five C’s</a> of credit system. Five C’s stands for:</p><ul><li><strong><em>Character</em></strong> — a borrower’s reputation or track record for repaying debts, credit history (record of consumer’s ability to repay a loan).</li><li><strong><em>Capacity</em></strong> —comparing one’s income against <a href="https://www.investopedia.com/terms/r/recurring_debt.asp">recurring debts</a> and assessing the borrower’s <a href="https://www.investopedia.com/terms/d/dti.asp">debt-to-income </a>(DTI) ratio. Recurring debts are any payments required to be made on continuing basis (e.g. child care support, loan). The debt-to-income ration determines whether enough income remains, after accounting for recurring debts, for the borrower to comfortably pay repay the loan.</li><li><strong><em>Capital</em></strong> — the amount of money a borrower puts towards potential investment. This practice is often applied to mortgages where some lenders require a downpayment of 2%-3% to assure the seriousness of the borrower.</li><li><strong><em>Collateral</em></strong> — an asset the that borrow provides to secure the loan. This is often a car for car loans, home for mortgages or even bank saving deposits for personal loans.</li><li><strong><em>Conditions</em></strong> — this includes everything from the conditions of the loan (e.g. interested rate) to conditions, outside of borrowers control (e.g. the state of the economy).</li></ul><p>Lenders’ decision whether to issue credit is highly influenced by the borrower’s <a href="https://www.investopedia.com/terms/c/credit_score.asp">credit score</a> and <a href="https://www.investopedia.com/terms/c/creditreport.asp">credit report</a> provided by the biggest credit bureaus in the US — Equifax, Experian, and TransUnion. The most common credit score system is <a href="https://www.investopedia.com/terms/f/fico-fair-isaac.asp">FICO (Fair Isaac Corporation)</a> which ranges between 300 and 850. FICO is based on the Five C’s system. The higher the FICO score, the more creditworthy is an individual.</p><p>Calculating FICO score varies for every individual but the key components which take place in any calculation are payment history, credit history, accounts owned, new credit and <a href="https://www.investopedia.com/terms/c/credit-mix.asp">credit mix</a> (all types of accounts — student loan, mortgages etc).</p><p>Lending companies follow the <em>FICO</em> <em>score</em> rigorously and rarely allow any exceptions. Due to the limited number of features, a <em>FICO score</em> comes with some downsides, including:</p><ul><li><strong><em>Assessing credit worthiness based on a limited number of features</em></strong>. This leads to performing more general decision which is not necessarily tailored to customer’s needs.</li><li><strong><em>Disqualifying potentially creditworthy people due to inability to match certain criteria.</em></strong> For instance, one’s credit history has big impact on the final score. This automatically excludes young individuals (students) or people from 3rd world countries (mainly Africa). In addition, a person is likely to not receive favorable terms on a loan if he/she has one or more late payments. All in all, assessing one’s credit worthiness may lead to false conclusions which result in a loss for both the lender and the borrower.</li><li><strong><em>FICO scoring system has little competition in the credit scoring industry.</em></strong> Since most lenders obtain borrower’s FICO score from the 3 major credit bureaus, if a potentially creditworthy borrower is rejected for a loan by a certain lender, he/she is likely to be rejected everywhere.</li><li><strong><em>Inability to match user’s demands.</em></strong> Due to the technological revolution experienced in the past 10 years, customer’s expectations for speed, accuracy and ease of use have increased exponentially. Existing credit issuers and credit bureaus need to accommodate customer’s needs or will be replaced by newly formed enterprises which pay special attention on their clients’ experience.</li></ul><p>The aforementioned problems force us to think of better approaches to enhance existing solutions or create entirely new ones. The machine learning revolution is coming at the right time for engineers and enterprises to act accordingly. In the next section, I will explain how and what ML models and techniques can be used for assessing credit worthiness.</p><h3>Machine Learning and Deep Learning Approach to Assessing Credit Worthiness</h3><figure><img alt="Photo with a title “Data has a better idea” representing DL and ML algorithms." src="https://cdn-images-1.medium.com/max/1024/1*7zKjE0bIN7pzZaU_y5558Q.jpeg" /></figure><p>For more than a decade, standard machine learning techniques have been applied to assess credit worthiness. For example, <a href="https://res.mdpi.com/risks/risks-06-00038/article_deploy/risks-06-00038-v2.pdf">this paper from April 2018</a> compares the performance of several algorithms (3 machine learning and 3 deep learning) to determine whether a company will default on a bank loan. The 3 machine learning algorithms are <a href="https://en.wikipedia.org/wiki/Elastic_net_regularization"><em>elastic net</em></a> (extension of logistic regression),<em> </em><a href="https://towardsdatascience.com/understanding-random-forest-58381e0602d2"><em>random forest</em></a> and <a href="https://towardsdatascience.com/understanding-gradient-boosting-machines-9be756fe76ab"><em>gradient boosting</em></a>. It is observed that <strong>gradient boosting outperforms all models</strong>, including the deep learning based ones. This is a proof that, using a correct feature engineering, standard machine learning techniques are still relevant for assessing credit worthiness.</p><p>However, the potential of deep learning can’t be ignored and <strong>it is just a matter of time when DL models will surpass standard ML ones for tasks like credit risk assessment.</strong> <a href="https://onlinelibrary.wiley.com/doi/pdf/10.1002/isaf.1437">Another paper from 2018</a>, explores the possibility of applying deep neural network to predict credit card deliquesces. The 5-layer DNN is evaluated on a dataset obtained from a large bank in Brazil, containing 711,397 records of credit card owners where 0.92 are delinquent. The model outperforms existing solutions like <a href="https://towardsdatascience.com/decision-trees-in-machine-learning-641b9c4e8052"><em>decision trees</em></a>, <a href="https://towardsdatascience.com/naive-bayes-classifier-81d512f50a7c"><em>naive Bayes</em></a> and <a href="https://towardsdatascience.com/logistic-regression-detailed-overview-46c4da4303bc"><em>logistic regression</em></a> both on the <a href="https://en.wikipedia.org/wiki/F1_score">F1 score </a>and overall accuracy.</p><p>In the latter research, it is shown that deep neural networks are really good at detecting risky customers on complex and highly unstructured data. As more data becomes available and more people are capable of running heavy DNN models using low cost computing power, deep neural networks will undoubtedly become the standard way of dealing with credit risk predictions.</p><h3>Problems with Deep Learning for Assessing Credit Worthiness</h3><figure><img alt="Scattered puzzle pieces indicating problems and chanllenges." src="https://cdn-images-1.medium.com/max/1024/1*a5N4vokpfnlmUnnJMou9zw.jpeg" /></figure><p>Even though DL models have shown potential to transform the way credit risk is evaluated, some challenges still remain unsolved.</p><p>One such difficulty lies in the fact that <strong>deep learning models need to have a certain level of explainability.</strong> In other words, governments require lenders to present sound arguments on why the credit decision is considered fair and unbiased. However, deep neural networks act as black-box models and data scientists find it hard to explain the reasons behind an output.</p><p>Currently, an intense research is undergoing to find answers to this problem. For example, researchers at the biggest AI conference —<a href="https://nips.cc/Conferences/2018"> NIPS 2018</a> has dedicated the finance workshop to the topic <em>“Challenges and Opportunities for AI in Financial Services: the Impact of Fairness, Explainability, Accuracy, and Privacy”</em>. This includes some interesting propositions like <a href="https://arxiv.org/abs/1811.07698">“Towards Global Explanations for Credit Risk Scoring”</a> where the researchers at BBVA bank sample the decision function of a complex DNN model to learn an alternative and more explainable classifier. Another approach, <a href="https://arxiv.org/abs/1811.05245">“Interpretable Credit Application Predictions With Counterfactual Explanations”</a>, aims to generate counterfactual explanations for every output. These explanations are in the form of plain text and share reasons for the specific decision (issue a loan or not) as well as the minimum change required in inputs to flip the outcome. An example explanation may be:</p><blockquote>Your application was denied because your annual income is $30,000 and your current balance is $200. If your income had instead been $35,000 and your current balance had been $400 and all other values remained constant, your application would have been approved.</blockquote><p>Despite such challenges, industry players confidently apply deep learning techniques for more efficient decision making. Companies like <a href="https://www.upstart.com/">Upstart</a> (personal loans using non-traditional variables), <a href="https://www.sofi.com/">SoFi</a> (online student loads, mortgages and personal loans) and <a href="https://www.affirm.com/">Affirm</a> (microloans for consumers to use at the point of sale to finance a purchase) have already integrated DL in their decision making processes.</p><p>As technology advances, <strong>more companies will be started on the vision to create fast, affordable and personalized experience for lending money.</strong> Existing enterprises would either adapt this new way of decisions making or be replaced by new comers.</p><h3><strong>Thank you for the reading. Hope you enjoyed the article 🤩 and I wish you a great day!</strong></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61a9e21cf179" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/the-future-of-lending-money-is-deep-learning-61a9e21cf179">The Future of Lending Money Is Deep Learning</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[Understanding Encoder-Decoder Sequence to Sequence Model]]></title>
            <link>https://medium.com/data-science/understanding-encoder-decoder-sequence-to-sequence-model-679e04af4346?source=rss-5cdfd010517e------2</link>
            <guid isPermaLink="false">https://medium.com/p/679e04af4346</guid>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[recurrent-neural-network]]></category>
            <dc:creator><![CDATA[Simeon Kostadinov]]></dc:creator>
            <pubDate>Tue, 05 Feb 2019 01:41:55 GMT</pubDate>
            <atom:updated>2019-11-10T11:12:59.007Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VSc2CM7b-ZIon95AFyFUAw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/TrhLCn1abMU?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Capturing the human heart.</a> on <a href="https://unsplash.com/search/photos/mapping?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>In this article, I will try to give a short and concise explanation of the sequence to sequence model which have recently achieved significant results on pretty complex tasks like machine translation, video captioning, question answering etc.</p><p><em>Prerequisites: the reader should already be familiar with neural networks and, in particular, recurrent neural networks (RNNs). In addition, knowledge of LSTM or GRU models is preferable. If you are not yet familiar with RNNs, I recommend reading </em><a href="https://towardsdatascience.com/learn-how-recurrent-neural-networks-work-84e975feaaf7"><em>this article</em></a><em> which will give you a quick start. For LSTM and GRU, I suggest looking into </em><a href="http://colah.github.io/posts/2015-08-Understanding-LSTMs/"><em>“Understanding LSTM Networks”</em></a><em> as well as </em><a href="https://towardsdatascience.com/understanding-gru-networks-2ef37df6c9be"><em>“Understanding GRU Networks”</em></a><em>.</em></p><h3>Use Cases of the Sequence to Sequence Model</h3><p>A sequence to sequence model lies behind numerous systems which you face on a daily basis. For instance, seq2seq model powers applications like Google Translate, voice-enabled devices and online chatbots. Generally speaking, these applications are composed of:</p><ul><li><em>Machine translation</em> — a 2016 <a href="https://arxiv.org/pdf/1409.3215.pdf">paper</a> from Google shows how the seq2seq model’s translation quality “approaches or surpasses all currently published results”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D2eqzElv414FFFAN1hg0WQ.png" /></figure><ul><li><em>Speech recognition </em>— another Google <a href="https://www.isca-speech.org/archive/Interspeech_2017/pdfs/0233.PDF">paper</a> compares the existing seq2seq models on the speech recognition task.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*NM_l6Ww2kQeEms_opuXxAg.png" /></figure><ul><li><em>Video captioning</em> — a 2015 <a href="https://arxiv.org/pdf/1505.00487.pdf">paper</a> shows how a seq2seq yields great results on generating movie descriptions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lQGaPX7Vy1Q_s1sc5N_IXw.png" /></figure><p>These are only some applications where seq2seq is seen as the best solution. This model can be used as a solution to any sequence-based problem, especially ones where the inputs and outputs have different sizes and categories. We will talk more about the model structure below.</p><h3>Definition of the Sequence to Sequence Model</h3><p><a href="https://arxiv.org/pdf/1409.3215.pdf">Introduced for the first time in 2014 by Google</a>, a sequence to sequence model aims to map a fixed-length input with a fixed-length output where the length of the input and output may differ.</p><p>For example, translating “What are you doing today?” from English to Chinese has input of 5 words and output of 7 symbols (今天你在做什麼？). Clearly, we can’t use a regular LSTM network to map each word from the English sentence to the Chinese sentence.</p><p>This is why the sequence to sequence model is used to address problems like that one.</p><h3>How the Sequence to Sequence Model works?</h3><p>In order to fully understand the model’s underlying logic, we will go over the below illustration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1JcHGUU7rFgtXC_mydUA_Q.jpeg" /><figcaption>Encoder-decoder sequence to sequence model</figcaption></figure><p>The model consists of 3 parts: encoder, intermediate (encoder) vector and decoder.</p><h4><strong>Encoder</strong></h4><ul><li>A stack of several recurrent units (LSTM or GRU cells for better performance) where each accepts a single element of the input sequence, collects information for that element and propagates it forward.</li><li>In question-answering problem, the input sequence is a collection of all words from the question. Each word is represented as <em>x_i</em> where <em>i</em> is the order of that word.</li><li>The hidden states <em>h_i </em>are computed using the formula:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sKqGIDJm3P8DeSwl0WHGkg.png" /></figure><p>This simple formula represents the result of an ordinary recurrent neural network. As you can see, we just apply the appropriate weights to the previous hidden state <em>h_(t-1) </em>and the input vector <em>x_t.</em></p><h4>Encoder Vector</h4><ul><li>This is the final hidden state produced from the encoder part of the model. It is calculated using the formula above.</li><li>This vector aims to encapsulate the information for all input elements in order to help the decoder make accurate predictions.</li><li>It acts as the initial hidden state of the decoder part of the model.</li></ul><h4>Decoder</h4><ul><li>A stack of several recurrent units where each predicts an output <em>y_t</em> at a time step <em>t</em>.</li><li>Each recurrent unit accepts a hidden state from the previous unit and produces and output as well as its own hidden state.</li><li>In the question-answering problem, the output sequence is a collection of all words from the answer. Each word is represented as <em>y_i</em> where <em>i</em> is the order of that word.</li><li>Any hidden state <em>h_i </em>is<em> </em>computed using the formula:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sdxvcjeV7NOUsR_VQ_nrUQ.png" /></figure><p>As you can see, we are just using the previous hidden state to compute the next one.</p><ul><li>The output <em>y_t</em> at time step <em>t</em> is computed using the formula:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y5T2-J2mrCRZp5M9Q4METw.png" /></figure><p>We calculate the outputs using the hidden state at the current time step together with the respective weight W(S). <a href="https://www.youtube.com/watch?v=LLux1SW--oM">Softmax</a> is used to create a probability vector which will help us determine the final output (e.g. word in the question-answering problem).</p><p><strong>The power of this model lies in the fact that it can map sequences of different lengths to each other.</strong> As you can see the inputs and outputs are not correlated and their lengths can differ. This opens a whole new range of problems which can now be solved using such architecture.</p><h4>Further Reading</h4><p>The above explanation just covers the simplest sequence to sequence model and, thus, we cannot expect it to perform well on complex tasks. The reason is that using a single vector for encoding the whole input sequence is not capable of capturing the whole information.</p><p>This is why multiple enhancements are being introduced. Each one aims to strengthen the performance of this model on slightly complex tasks with long input and output sequences. Examples are:</p><ul><li><a href="https://arxiv.org/pdf/1409.3215.pdf">Reversing the order of the input sequence</a>.</li><li>Using LSTM or GRU cells.</li><li><a href="http://www.wildml.com/2016/01/attention-and-memory-in-deep-learning-and-nlp/">Introducing Attention mechanism</a>.</li><li>and many more.</li></ul><p>If you want to strengthen your knowledge of this wonderful deep learning model, I strongly recommend watching <a href="https://youtu.be/QuELiw8tbx8?list=PL3FW7Lu3i5Jsnh1rnUwq_TcylNr7EkRe6&amp;t=1190">Richard Socher’s lecture on Machine Translation</a>. If you still feel lost or have any questions, please ask in the comment section and I would be happy to help.</p><p>I hope this article is leaving you with a good understanding of the state-of-the-art model for dealing with sequences (seq2seq) and managed to contribute to your exciting deep learning journey.</p><blockquote>What more AI content? <a href="https://www.linkedin.com/in/simeonkostadinov/">Follow me on LinkedIn</a> for daily updates.</blockquote><h4>Thank you for reading. If you enjoyed the article, give it some claps 👏 . Hope you have a great day!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=679e04af4346" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/understanding-encoder-decoder-sequence-to-sequence-model-679e04af4346">Understanding Encoder-Decoder Sequence to Sequence Model</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[Key Steps for Building an Effective AI Organization]]></title>
            <link>https://medium.com/data-science/key-steps-for-building-an-effective-ai-organization-cad45b1992d7?source=rss-5cdfd010517e------2</link>
            <guid isPermaLink="false">https://medium.com/p/cad45b1992d7</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[management]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[innovation]]></category>
            <category><![CDATA[business-strategy]]></category>
            <dc:creator><![CDATA[Simeon Kostadinov]]></dc:creator>
            <pubDate>Mon, 21 Jan 2019 03:08:08 GMT</pubDate>
            <atom:updated>2019-01-21T08:29:54.572Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JYGU_MEBZaJfWw4HnQtvcg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/ymf4_9Y9S_A?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Randy Fath</a> on <a href="https://unsplash.com/collections/2500743/building-and-construction?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Recently, I got fascinated by the impact of artificial intelligence on any business from any sector (tech, banking, manufacturing, etc.) This led me to explore the subject further while trying to understand what a corporation should do to transform its processes using AI.</p><p>In this article, I would love to summarize my observations into a set of actionable steps which can help any organization kickstart their AI transformation. My thoughts are heavily influenced by the amazing 12-page paper, written by Andrew Ng — founder of Landing AI, called <a href="https://d6hi0znd7umn4.cloudfront.net/content/uploads/2018/12/AI-Transformation-Playbook.pdf">“AI Transformation Playbook”</a>. In addition, I have taken advice from numerous McKinsey&amp;Company reports like <a href="https://www.mckinsey.com/industries/financial-services/our-insights/mckinsey-on-payments-special-edition-on-advanced-analytics-in-banking">“McKinsey on Payments: Special Edition on Advanced Analytics in Banking”</a>.</p><h3>#1. What Problems Do Organizations Face When Deploying AI?</h3><p>Organizations which fail to transform their operations with AI algorithms and data often face one or more of the following challenges:</p><ul><li>Failure to plan and strategically make the first steps.</li><li>Not focusing on delivering business value.</li><li>Lack of commitment from senior management.</li><li>Inability to find AI talent.</li></ul><p>Let’s examine each problem individually.</p><h4><strong>Failure to plan and strategically make the first steps</strong></h4><p>If an organization is determined to pilot and start deploying AI capabilities, it has to diligently prepare the process. This includes choosing the right pilot project, estimating the time of delivery, communicating with the business unit(s) and more.</p><p>An incorrect way to start is hiring several data engineers/scientists, isolating them from the rest of the company with a hope to do their magic. Unfortunately, nothing sufficient will be delivered which will lead to a fake conclusion that an AI transformation is not suitable for this organization.</p><p>Later on, I will list practical tips which will guide you towards an effective planning.</p><h4><strong>Not focusing on delivering business value</strong></h4><p>I will allow myself to quote Andrew Ng who says that an initial pilot needs to <em>“have a clearly defined and measurable objective that creates business value”</em>.</p><p>If the AI team misses to deliver measurable results which directly impact the bottom line, the pilot outcomes may be seen too insignificant which can lead to reduced funding and lack of freedom to experiment further with AI.</p><p>This challenge can be overcome with strategic and careful planning on where the initial effort of the AI team should go.</p><h4><strong>Lack of commitment from senior management</strong></h4><p>Focusing senior management’s attention on a new and experimental process is a challenging but not impossible task which most AI teams will face. It is highly related to the previous point of <strong>focusing on delivering business value</strong>.</p><p>Top management and the AI team should constantly be in a transparent communication, so that the projects’ focus remains on delivering useful results to the organization.</p><h4><strong>Inability to find AI talent</strong></h4><p>At the moment, there is a huge shortage of people who are capable of producing meaningful results using AI techniques. Most PhD students in advanced computer science degrees navigate towards the biggest tech giants.</p><p>Companies in the finance, manufacturing, telecommunications, pharmaceutical and other sectors are left without the opportunity to build a strong in-house AI team to attack complex problems.</p><p>Fortunately, this challenge is likely present only in the short-term and, eventually, organizations will be able to hire educated people.</p><p>But, at this very moment, companies should look for innovative ways of gathering AI talent. I will outline some useful approaches below.</p><h3>#2. Actionable Steps Towards Your AI Transformation</h3><p>Your organization’s AI transformation goes through several stages starting with carefully chosen pilot projects and slowly establishing an AI unit which empowers every other business unit.</p><h4><strong>Start with pilot projects</strong></h4><p>Andrew Ng states that <em>“it is more important for your first few AI projects to succeed rather than be the most valuable AI projects” </em>and<em> </em>adding that<em> “the important thing is to get the flywheel spinning so that your AI team can gain momentum”.</em></p><p>The above statement leads us to the following set of strategies:</p><ol><li><strong>AI pilot projects should be performed by a separate AI team</strong> (I have outlined details about the AI team in the next section).</li><li>The first <strong>AI projects should be directly linked</strong> <strong>to the organization’s business strategy.</strong></li><li>To make sure business value is delivered, the <strong>AI team should collaborate closely with an internal team</strong> with a deep knowledge of the business. This will assure AI solutions for existing problems are being built.</li><li>These first<strong> AI projects should produce measurable results</strong> which can be explained (with numbers) to the executive committee.</li><li><strong>Value</strong> from the projects <strong>should be delivered as soon as possible</strong> (less than 18 months).</li><li>The AI team should form a robust and concise plan of the <strong>project’s scope</strong>, so it is <strong>technologically feasible and does not cover too much at once</strong>. Often companies fail to evaluate the power of AI, thinking that many complex problems could be solved with this technology.</li></ol><p>Once your initial pilots gain traction and bring business value to the table, other units of your corporation would be opened to conversations with the AI team to start exploring possibilities for a transformation.</p><h4><strong>Forming your AI team</strong></h4><p>As mentioned above, establishing a strong in-house AI team is quite challenging due to high supply but low demand of experienced people.</p><p>This will likely change in the long-term with the help of people like Andrew Ng and his <a href="https://www.coursera.org/courses?query=deeplearning.ai">deeplearning.ai courses</a>, Siraj Raval and<a href="https://www.theschool.ai/"> School of AI</a> and numerous books and courses like my most recent book <a href="https://amzn.to/2AWQIND">“Recurrent Neural Networks with Python Quick Start Guide”</a>.</p><p>In order to take action right now, companies might need to use slightly non-trivial approaches. Several of them include:</p><ul><li><strong>Outsource the AI team</strong></li></ul><p>Your organization can hire an external supplier of data engineers/scientists to build all AI solutions.</p><p>This approach is recommended for smaller and not so critical projects. Ideally, you should have the “brain” of your AI team in-house and outsource projects which require unique sources of data and advanced solutions.</p><ul><li><strong>Partner with other organizations to access AI talent</strong></li></ul><p>A recent McKinsey&amp;Company report explains how a large retail organization developed a strategic partnership with a startup incubator which gave them access to numerous small companies with talent already in place. Mixing such collaborations with a core AI internal team can boost your transformation.</p><ul><li><strong>Provide broad AI training</strong></li></ul><p>The idea of training your staff is most efficient for the long-term but it comes with higher number of challenges.</p><p>First, you need to consult with an expert in the AI field who had lead this operation and steer the direction to the correct way.</p><p>Second, your CLO (Chief Learning Officer) needs to carefully curate the content provided for the training. This includes online video tutorials, paid courses, ebooks etc.</p><p>Finally, your organization needs to provide training procedures for every role (executive leaders, division/business unit managers and AI engineers/data scientists).</p><p>To make sure these steps are executed correctly, your organization may need the help of an external partner like <a href="https://landing.ai/">Landing AI</a> which, at the moment, aims to empower manufacturing companies with AI techniques.</p><p><em>The choice of how to form your AI team is not an all-or-nothing decision and you will most likely mix the above approaches to achieve needed results.</em></p><p>Every company’s in-house AI team will be structured slightly differently. In this section, I will give an example breakdown which includes data scientists, data engineers, workflow integrators, data architects, delivery managers, visualization analysts, and translators. Let’s examine each role:</p><ul><li>The <strong>translator</strong> communicates with the business owner to identify and prioritize the business request.</li><li>The <strong>data scientist</strong> works with the translator to develop a specific use case.</li><li>A <strong>data engineer</strong> works with the relevant business division to understand the data characteristics (requirements, source etc.) of the use case.</li><li>A data scientist programs the algorithm and analyzes the data in the sandbox to generate insights.</li><li>A <strong>visualization analyst</strong> develops reports and dashboards for business users.</li><li>A <strong>workflow integrator</strong> works with the business owner to develop a prototype for models and tools.</li><li>A <strong>delivery manager</strong> pilots the prototype and dashboard and works to obtain a pass or fail decision.</li><li>The delivery manager and workflow integrator work with the IT department to scale the prototype to the enterprise level.</li><li>The delivery manager and translator work with the business and IT to ensure adoption and ongoing model maintenance.</li></ul><p>As you can see there is constant communication between the AI team (through translator, workflow integrator and delivery manager) and the particular business unit. This is crucial for delivering a successful pilot project.</p><h4><strong>Make the AI unit a key component of your organization</strong></h4><p>In this final section, I would love to focus the attention on a broader picture and suggest how an AI unit can fit inside your organization.</p><p>Typically, large corporations are separated into sub-units (marketing, IT, legal, etc.) which report to senior management. <strong>For a full AI transformation to take place, new techniques should be adopted in every sector.</strong></p><p>The AI team can act as a separate centralized unit which will enhance different divisions with AI projects and talent. Eventually, these projects can be controlled and managed from the particular business unit.</p><p><em>Using the power of AI, your company can be transformed into a more effective organization which constantly stays ahead of the competitors. Your focus shouldn’t be on becoming a global AI leader, but instead on revolutionizing your specific processes with this technology.</em></p><h4>Thank you for the reading. If you enjoyed the article, give it some claps 👏 . Hope you have a great day!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cad45b1992d7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/key-steps-for-building-an-effective-ai-organization-cad45b1992d7">Key Steps for Building an Effective AI Organization</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[My impression of Stanford’s Tensorflow course: Assignment 1]]></title>
            <link>https://medium.com/@simonnoff/my-impression-of-stanfords-tensorflow-course-assignment-1-ed368af28d73?source=rss-5cdfd010517e------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed368af28d73</guid>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[stanford]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Simeon Kostadinov]]></dc:creator>
            <pubDate>Tue, 20 Mar 2018 22:59:53 GMT</pubDate>
            <atom:updated>2018-04-09T00:29:06.712Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*seCTwbbSiau0WjZIw2RT9g.png" /><figcaption>Stanford University</figcaption></figure><p>The first assignment of this course covers 3 main problems. The first one is simply filling in missing chunks of code to solve simple tasks. The second one is implementation of a deep neural network model which gives 97%+ accuracy on the MNIST dataset. And the third one is to implement the CBOW model. You can find the assignment <a href="https://docs.google.com/document/d/1CpBvivgmo_4sMmnlWqjFAXTXKa_bI9dJVSQLPZIu7Vg/edit">here</a>.</p><h4>#1. Problem 1</h4><p>This part primarily tests your basic Tensorflow knowledge.</p><p><strong><em>a) Problem:</em></strong><em> Create two random 0-d tensors x and y of any distribution. Create a TensorFlow object that returns x + y if x &gt; y, and x — y otherwise. Hint: look up tf.cond()</em></p><p><strong><em>Solution:</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aefa66fe12e76ebcc81fa3a5b92d4b2f/href">https://medium.com/media/aefa66fe12e76ebcc81fa3a5b92d4b2f/href</a></iframe><p><strong><em>Reference:</em></strong><em> </em><a href="https://www.tensorflow.org/api_docs/python/tf/cond"><em>tf.cond()</em></a></p><p><strong><em>b) Problem:</em></strong><em> Create two 0-d tensors x and y randomly selected from the range [-1, 1). Return x + y if x &lt; y, x — y if x &gt; y, 0 otherwise. Hint: Look up tf.case().</em></p><p><strong><em>Solution:</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab7be831440c3176e468cf04d5b70205/href">https://medium.com/media/ab7be831440c3176e468cf04d5b70205/href</a></iframe><p><strong><em>Reference:</em></strong><em> </em><a href="https://www.tensorflow.org/api_docs/python/tf/case"><em>tf.case()</em></a></p><p><strong><em>c) Problem:</em></strong><em> Create the tensor x of the value [[0, -2, -1], [0, 1, 2]] and y as a tensor of zeros with the same shape as x. Return a boolean tensor that yields Trues if x equals y element-wise. Hint: Look up tf.equal().</em></p><p><strong><em>Solution:</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/28cfdac67a234b25c8e6c56157bf6b3c/href">https://medium.com/media/28cfdac67a234b25c8e6c56157bf6b3c/href</a></iframe><p><strong><em>Reference:</em></strong><em> </em><a href="https://www.tensorflow.org/api_docs/python/tf/zeros_like"><em>tf.zeros_like()</em></a><em> and </em><a href="https://www.tensorflow.org/api_docs/python/tf/equal"><em>tf.equal()</em></a></p><p><strong><em>d) Problem:</em></strong><em> Create the tensor x of value [29.05088806, 27.61298943, 31.19073486, 29.35532951, 30.97266006, 26.67541885, 38.08450317, 20.74983215, 34.94445419, 34.45999146, 29.06485367, 36.01657104, 27.88236427, 20.56035233, 30.20379066, 29.51215172, 33.71149445, 28.59134293, 36.05556488, 28.66994858]. Get the indices of elements in x whose values are greater than 30. Hint: Use tf.where(). Then extract elements whose values are greater than 30. Hint: Use tf.gather().</em></p><p><strong><em>Solution:</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/77955b64db831864f1aec0a514f06c27/href">https://medium.com/media/77955b64db831864f1aec0a514f06c27/href</a></iframe><p><strong><em>Reference:</em></strong><a href="https://www.tensorflow.org/api_docs/python/tf/where"><strong><em> </em></strong><em>tf.where()</em></a></p><p><strong><em>e) Problem:</em></strong><em> Create a diagonal 2-d tensor of size 6 x 6 with the diagonal values of 1, 2, …, 6. Hint: Use tf.range() and tf.diag().</em></p><p><strong><em>Solution:</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d13b0a23a0d20626fef66269d7c9747/href">https://medium.com/media/5d13b0a23a0d20626fef66269d7c9747/href</a></iframe><p><strong><em>Reference:</em></strong><em> </em><a href="https://www.tensorflow.org/api_docs/python/tf/diag"><em>tf.diag()</em></a></p><p><strong><em>f) Problem:</em></strong><em> Create a random 2-d tensor of size 10 x 10 from any distribution. Calculate its determinant. Hint: Look at tf.matrix_determinant().</em></p><p><strong><em>Solution:</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a2b0a2f313ba272c5dbda6786134ad8/href">https://medium.com/media/6a2b0a2f313ba272c5dbda6786134ad8/href</a></iframe><p><strong><em>Reference:</em></strong><em> </em><a href="https://www.tensorflow.org/api_docs/python/tf/random_uniform"><em>tf.random_uniform</em></a><em> and </em><a href="https://www.tensorflow.org/api_docs/python/tf/matrix_determinant"><em>tf.matrix_determinant()</em></a><em> — </em><a href="https://en.wikipedia.org/wiki/Determinant"><em>matrix determinant explanation</em></a><em>.</em></p><p><strong><em>g) Problem:</em></strong><em> Create tensor x with value [5, 2, 3, 5, 10, 6, 2, 3, 4, 2, 1, 1, 0, 9]. Return the unique elements in x. Hint: use tf.unique(). Keep in mind that tf.unique() returns a tuple.</em></p><p><strong><em>Solution:</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bdfe19c43d679caf733dcaa31f21ec05/href">https://medium.com/media/bdfe19c43d679caf733dcaa31f21ec05/href</a></iframe><p><strong><em>Reference:</em></strong><em> </em><a href="https://www.tensorflow.org/api_docs/python/tf/unique"><em>tf.unique()</em></a></p><p><strong><em>h) Problem:</em></strong><em> Create two tensors x and y of shape 300 from any normal distribution, as long as they are from the same distribution. Use tf.cond() to return:</em></p><p><em>— The mean squared error of (x — y) if the average of all elements in (x — y) is negative, or</em></p><p><em>— The sum of absolute value of all elements in the tensor (x — y) otherwise.</em></p><p><em>Hint: see the Huber loss function in the lecture slides 3.</em></p><p><strong><em>Solution:</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b0a118c6d2fb60e9b4853b008cfd69c/href">https://medium.com/media/5b0a118c6d2fb60e9b4853b008cfd69c/href</a></iframe><h4>#2. Problem 2</h4><p>This task has 2 parts — <em>improve the logistic regression model to achieve 97%+ accuracy on MNIST dataset</em> or <em>build a new logistic regression model on the nonMNIST dataset</em>.</p><p>I started tweaking the <a href="https://machinelearningmastery.com/difference-between-a-parameter-and-a-hyperparameter/">hyperparameters</a> of <a href="https://docs.google.com/document/d/1kMGs68rIHWHifBiqlU3j_2ZkrNj9RquGTe8tJ7eR1sE/edit#heading=h.a4lz94ypirbn">this model</a> with <a href="https://github.com/chiphuyen/stanford-tensorflow-tutorials/blob/master/examples/03_logreg_starter.py">the example code</a>. I also changed the activation functions and did some other slight improvements. Unfortunately, non of my attempts ended up having 97%+ result on the test data. If you manage to find the appropriate changes, I am happy to see them in the comment section.</p><p>So, I searched for the models which produce the best results and found this nice <a href="http://yann.lecun.com/exdb/mnist/">list</a> which inspired me to try doing a simple 3-layer convolutional neural network.</p><p>I will now explain the full implementation below. Bear in mind that it may seem a blackbox to you but you will get a better understanding of convolution neural networks in my next article.</p><p>This code below follows <a href="https://www.tensorflow.org/tutorials/layers">this Tensorflow example</a>.</p><p>Let’s begin step-by-step:</p><ul><li>Import the libraries</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/360c1e8dc3dce0bb3022074ff57dd8a1/href">https://medium.com/media/360c1e8dc3dce0bb3022074ff57dd8a1/href</a></iframe><p><em>numpy</em> and <em>tensorflow</em> should be fairly familiar, <em>utils</em> is used to load the MNIST dataset. In general, <a href="https://pypi.python.org/pypi/utils/0.9.0"><em>utils</em></a> is used to collect the most common functions and operations used in python.</p><ul><li>Build the convolutional neural network</li></ul><p>It consists of 2 convolutional layers, each of them followed by a max-pool layer and there is a dense layer in the end.</p><p><em>Convolutional layer </em>— produces feature maps after applying a filter window to the input (initially it is the image itself)</p><p><em>Pooling layer </em>— used to reduce the size of the image representation during training.</p><p><em>Dense layer</em> — this is the final layer in the model and it is a result of full connection between all neurons in the previous layer.</p><p>You can find the difference these layers <a href="http://forums.fast.ai/t/dense-vs-convolutional-vs-fully-connected-layers/191/3">here</a>. Additionally, <a href="https://medium.com/technologymadeeasy/the-best-explanation-of-convolutional-neural-networks-on-the-internet-fbb8b1ad5df8">here</a> is a brief explanation of CNN.</p><p>#0. Our model function receives the input <em>data</em> (images) and <em>labels</em> as parameters. In addition we add <em>mode</em> which is used for Tensorflow Estimator which I will explain below.</p><p>#1. Reshape the input</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d613de7c232c860411af5d218b0376a/href">https://medium.com/media/5d613de7c232c860411af5d218b0376a/href</a></iframe><p>We reshape data following the concept: <strong>[batch_size, image_width, image_height, num_channels]</strong>. Since the images are grayscale, the num_channels is 1. batch_size is set to -1 which means that <em>this dimension should be dynamically computed based on the number of input values.</em></p><p>#2. First conv layer</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7be26c9cabf4c729f4e2968d121ca160/href">https://medium.com/media/7be26c9cabf4c729f4e2968d121ca160/href</a></iframe><p>We use Tensorflow <a href="https://www.tensorflow.org/api_docs/python/tf/layers/conv2d"><em>tf.layers.conv2d()</em></a><em> </em>function. Let me quickly explain what each parameter mean:</p><ul><li><em>input_layer</em> — the current input matrix, it can be the initial image or a reformed version of it.</li><li><em>filters</em> — after convoluting the input with a window of size (kernel_size), we receive a new matrix where its (width, height)=(input_layer.width — kernel_size.width + 1, input_layer.height— kernel_size.height + 1). The filters determine the number of matrices of the above size, stacked together.</li><li><em>kernel_size </em>— the size of the window which will be slided over the input matrix.</li><li><em>padding</em> — the type of padding we need to use when reaching the edges of the input matrix window. See more information <a href="https://stackoverflow.com/questions/37674306/what-is-the-difference-between-same-and-valid-padding-in-tf-nn-max-pool-of-t">here</a>.</li><li><em>activation</em> — apply <a href="https://en.wikipedia.org/wiki/Rectifier_(neural_networks)">relu</a> function which transforms every neuron value (if less than 0, go to 0, otherwise remains the same)</li></ul><p>#3. First max pool layer</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a4fec32a1d0e8c6bf782816f69ef8d2b/href">https://medium.com/media/a4fec32a1d0e8c6bf782816f69ef8d2b/href</a></iframe><p>We use the Tensorflow <a href="https://www.tensorflow.org/api_docs/python/tf/layers/max_pooling2d">tf.layers.max_pooling2d</a> to perform the max pool layer which reduces the size of the <em>conv1</em> matrix.</p><ul><li><em>pool_size </em>— the size of the window that we choose the highest value from.</li><li><em>strides </em>— the number of cells we need to slide over the <em>conv1</em> matrix.</li></ul><p>#4. Second conv layer</p><p>Same as the first convolutional layer with the only difference in the number of filters — here is 64.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/70de40046689e1b7168c67bd37830f25/href">https://medium.com/media/70de40046689e1b7168c67bd37830f25/href</a></iframe><p>#5. Second max pool layer</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f67ab4f89be83d0ed5b6210e4013d1d/href">https://medium.com/media/1f67ab4f89be83d0ed5b6210e4013d1d/href</a></iframe><p>#6. Dense layer</p><p>This is the final layer in the CNN.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7019136d895ba061e469eb95527dd3e7/href">https://medium.com/media/7019136d895ba061e469eb95527dd3e7/href</a></iframe><ul><li>First, we flatten the second max pool layer by reshaping it to 2-dimensional array, having 7 (width) * 7 (height) * 64 (depth) = 3136 neurons.</li><li>Using a typical dense layer with dimensionality of the output 1024. You can find more <a href="https://www.tensorflow.org/api_docs/python/tf/layers/dense">here</a>.</li><li>Applying dropout on the dense layer which randomly removes 40% (rate=0.4) of the units in order to prevent overfitting.</li><li>Finally, we get the final dense layer with 10 units — the number of different digits from 0–9.</li><li>Use <a href="https://stackoverflow.com/questions/41708572/tensorflow-questions-regarding-tf-argmax-and-tf-equal">tf.argmax</a> to get the classes.</li><li>Normalize the logits to be in the range (0, 1).</li></ul><p>#7. Loss and Optimizer</p><p>Let’s examine the loss function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a52e150a8dd9f0d8606767a6ee1a6a4/href">https://medium.com/media/4a52e150a8dd9f0d8606767a6ee1a6a4/href</a></iframe><ul><li>If we are in <em>predicting mode, </em>just return the estimator with prediction (see below the explanation of TF Estimator)</li><li>If we are in <em>training mode</em>, create onehot_labels of the based on the expected values of the model. You can understand how this transformation is done <a href="https://www.tensorflow.org/api_docs/python/tf/one_hot">here</a>.</li><li>Finally we calculate the loss function using <em>softmax_cross_entropy</em> with the expected values as <em>onehot_labels</em> and predicted values as <em>logits</em>. If the name <em>softmax_cross_entropy</em> sounds ambiguous to you, have a look at this <a href="https://www.quora.com/Is-the-softmax-loss-the-same-as-the-cross-entropy-loss">Quora answer</a> on the difference between <em>softmax</em> (type of activation function) and <em>cross_entropy</em> (loss function).</li></ul><p>Now let’s look at the optimizer:</p><p>It is used to update the weights in the direction that minimizes the loss function. The global_step is just for keeping track of the number of batches.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/57a58795a74f7cbd29dcf5a4d7380926/href">https://medium.com/media/57a58795a74f7cbd29dcf5a4d7380926/href</a></iframe><ul><li>We do the above steps only in <em>training mode.</em></li><li>For optimizer, we use a normal Gradient Descent Optimizer with learning rate 0.001. Here is <a href="http://ruder.io/optimizing-gradient-descent/">a nice list</a> with all the difference gradient optimizers.</li><li>Finally we minimize the loss function.</li></ul><p>In case of <em>evaluation mode,</em> we just return how often does the labels match the predictions using <a href="https://www.tensorflow.org/api_docs/python/tf/metrics/accuracy">tf.metric.accuracy</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/936dc0b2f5326cbcc9e11691522cd2ee/href">https://medium.com/media/936dc0b2f5326cbcc9e11691522cd2ee/href</a></iframe><p>The main purpose of the <strong>loss function</strong> and the <strong>optimizer</strong> is to adjust the weights of our network so that the error between our predicted values (<em>logits</em>) and the actual results (<em>labels</em>) is minimized and the prediction is as closer as possible to the truth.</p><p>#8. Tensorflow Estimator</p><p>A high-level Tensorflow API which helps training, evaluating and testing your model. You can read more about it in the <a href="https://www.tensorflow.org/programmers_guide/estimators">documentation</a>. I will explain below how our model uses this Estimator:</p><ul><li>One type of usage is: <a href="https://www.tensorflow.org/api_docs/python/tf/estimator/ModeKeys">tf.estimator.ModeKeys</a> which can be TRAIN, EVAL, PREDICT and determines the current mode.</li><li>Another type is: <a href="https://www.tensorflow.org/api_docs/python/tf/estimator/EstimatorSpec">tf.estimator.EstimatorSpec</a> which provides the information of the current state of the model to the main Estimator object.</li><li>You can also see creating the main Estimator object, using <a href="https://www.tensorflow.org/api_docs/python/tf/estimator/Estimator">tf.estimator.Estimator</a> which takes the model representation.</li><li>Finally, the function <a href="https://www.tensorflow.org/api_docs/python/tf/estimator/inputs/numpy_input_fn">tf.estimator.inputs.numpy_input_fn</a> gives representation of the data and using <em>.train</em> and <em>.evaluate</em>, we get the results of our model.</li></ul><h4>#3. Problem 3</h4><p>This task is in 3 parts where the most crucial one is 3c which asks you to implement CBOW model by tweaking the provided code for the skip-gram. In this article, I will only show how to implement 3c. If you have difficulties doing 3a and 3b, comment at the bottom and we can chat about it.</p><p>We will be modifying the <a href="https://github.com/chiphuyen/stanford-tensorflow-tutorials/blob/6223b07a83ad2124c0808f19c8d5ca858a1d848e/examples/04_word2vec_visualize.py">skip-gram code</a> by changing the following functions:</p><ul><li>_create_embedding (line 54):</li></ul><p>From <em>skip-gram</em>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/96820ea8f32fa29b36d57b8b990d7b47/href">https://medium.com/media/96820ea8f32fa29b36d57b8b990d7b47/href</a></iframe><p>From <em>CBOW</em>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/07709d265022434f7ec9708a3f9e8bd1/href">https://medium.com/media/07709d265022434f7ec9708a3f9e8bd1/href</a></iframe><ul><li>_create_loss (line 64):</li></ul><p>From <em>skip-gram</em>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c61210c8b8509ad7a7eb48bba3e6d8bc/href">https://medium.com/media/c61210c8b8509ad7a7eb48bba3e6d8bc/href</a></iframe><p>From <em>CBOW</em>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a00c2bc051284ee5b2e0ab535befdf3c/href">https://medium.com/media/a00c2bc051284ee5b2e0ab535befdf3c/href</a></iframe><p>For any enquiries regarding the modifications in the code, comment below or email me: <em>simeon dot kostadinoff at gmail dot com</em>.</p><h4>Thank you for the reading. If you enjoyed the article, give it some claps 👏 . Hope you have a great day!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed368af28d73" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My impression of Stanford’s Tensorflow course: Week 1–3]]></title>
            <link>https://medium.com/@simonnoff/my-impression-of-stanfords-tensorflow-course-week-1-3-57dc73920915?source=rss-5cdfd010517e------2</link>
            <guid isPermaLink="false">https://medium.com/p/57dc73920915</guid>
            <category><![CDATA[stanford]]></category>
            <category><![CDATA[word2vec]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Simeon Kostadinov]]></dc:creator>
            <pubDate>Tue, 27 Feb 2018 08:07:59 GMT</pubDate>
            <atom:updated>2018-04-09T00:28:39.029Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*seCTwbbSiau0WjZIw2RT9g.png" /><figcaption>Stanford University</figcaption></figure><p><a href="https://medium.com/@simonnoff/my-impression-of-stanfords-tensorflow-course-introduction-96b6054dc4ef">In my previous post</a> I gave a brief introduction to this new series of posts which aims to give an explanation of the most recent <a href="https://web.stanford.edu/class/cs20si/syllabus.html">Stanford’s Tensorflow course</a> from January-February 2018. In this part I will uncover my impressions of the first 3 weeks of this course.</p><h4>Week 1: Overview of Tensorflow</h4><p>This week provides is the best explanation of Tensorflow I have ever seen. Often, when one gets motivated to learn about machine learning, he may quickly be discourage by the complication and ambiguity of the original <a href="https://www.tensorflow.org/get_started/">Tensorflow documentation</a>.</p><p>I would recommend first go briefly through the <a href="https://docs.google.com/document/d/1gWm3uBnbU6wxZAm0VAiSV_8odzfaE7yEG1lW-NO34fI/edit#heading=h.d4hnkrrpy96m">lecture notes</a> and then jump into the <a href="https://docs.google.com/presentation/d/1dizKPtp9hkuTwVDzoGZdYQb_61ULSsSUvaFfDFuhIc4/edit#slide=id.g1bcfa4d819_0_364">slides</a>. The latter will give you this fluent start towards your understanding of TF.</p><h4>Week 2: Tensorflow operations + examples</h4><p>This week dives into the power of Tensorflow. First the course covers TF operations like constants, summation, multiplication etc. and the second lecture of the week reveals how to implement Linear regression.</p><h4>#1. TF operations</h4><p>Following the <a href="https://docs.google.com/document/d/1FSPNZFQsnaUVeTo0OQ2RrEZ0f4el9bIGI5sQALbG_F0/edit#">lecture notes</a>:</p><ol><li>You will get a nice understanding of <a href="https://www.tensorflow.org/programmers_guide/summaries_and_tensorboard">Tensorboard</a> — a suite of tools provided by TF used to visualize your graph (there are 2 steps when building a model in TF — forming your graph and then executing using specific data).</li><li>Then, the focus shifts to all the different ways of creating a constant. For example, one can easily make (n,m) matrix filled with 0-s. (<em>tf.zeros([n, m], tf.int32)</em>). Of course, you can do much more.</li><li>After that, all the math operations like addition, the 5+ different divisions, dot product etc. are explained in a wonderful way.</li><li>We all know there are certain types of numbers, like natural etc. In programming there are even more and of course the TF team wanted to cover all of them. So you will see what are they and how to use them.</li><li>Next, you are introduced to TF variables, They are different than constants in terms of usage. Variables are used to store values which can be update along the way — like weights and biases of a neural network.</li><li>Finally, you can see how to use<em> tf.Session()</em> which runs the graph using your imported data.</li></ol><h4>#2. Linear regression and Logistic regression for MNIST</h4><p>The <a href="https://docs.google.com/document/d/1kMGs68rIHWHifBiqlU3j_2ZkrNj9RquGTe8tJ7eR1sE/edit#heading=h.a8w2b79yy875">2nd lecture</a> of this week covers a some examples.</p><p>The first one is an implementation of linear regression for predicting life expectancy from birth rate — the model is fairly simple and you can find it <a href="https://github.com/chiphuyen/stanford-tensorflow-tutorials/blob/master/examples/03_linreg_placeholder.py">here</a>. If you follow the steps in the lecture notes, you will be able to run it yourself. Drop a message in the comment section if you have any questions.</p><p>The second example cover logistic regression for MNIST dataset (contains 30k + examples of handwritten images).</p><p>Linear and logistic regression sound familiar but they are completely different algorithms. Here is the difference:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6mUu7pBNiE6oRiv7Ymh2YQ.png" /></figure><h4>Week 3: Advanced TF techniques</h4><p>This week is again divided into 2 lectures. The first one covers <em>Eager execution</em> (find below) and the second one is entirely about <em>word2vec model</em> and some advanced techniques which come with it.</p><h4>#1. Eager execution</h4><p>As you are already familiar, building models in TF comes in 2 steps — forming the graph and executing it using <em>tf.Session()</em>. This (declarative) approach comes with many advantages but also some disadvantages. The main one is difficulty in debugging. This is where Eager execution come in. Recently, the TF team started working on it which offers an imperative execution of all operations. This means that you will be able to see the results of your model in runtime — isn’t that awesome ^^.</p><p>For better understanding, I would this time recommend going thought the <a href="https://docs.google.com/presentation/d/1e1gE2JJXipWm1UJgor_y8pHcM8L8oMaCVtvQvZUBlQY/edit#slide=id.g1c30b6cab2_0_0">slides</a> rather than the <a href="https://docs.google.com/document/d/1tLThJGHyMICyXwSIxyZ4D4cZ1hJ1Iuk8WFxe7gBBKa4/edit">lecture notes</a>. Both are useful but the slides (+ the notes under each slide) give wider perspective.</p><h4>#2. Word2vec</h4><p><a href="https://docs.google.com/document/d/1wqp8_-H06oE4zB9CHDwzTx5BfAOMM_6nnNJMSfkazkU/edit#heading=h.z3giweseabxf">This lecture</a> emphasizes on the implementation of <em>word2vec</em> model. It is used to give us a nice and powerful representation of words when we want to base our neural network on natural language.</p><p><em>Word2vec</em> can be used with 2 models — skip-gram and CBOW. Quoted from the lecture:</p><blockquote>Algorithmically, these models are similar, except that CBOW predicts center words from context words, while the skip-gram does the inverse and predicts source context-words from the center words. For example, if we have the sentence: “”The quick brown fox jumps””, then CBOW tries to predict “”brown”” from “”the””, “”quick””, “”fox””, and “”jumps””, while skip-gram tries to predict “”the””, “”quick””, “”fox””, and “”jumps”” from “”brown””.</blockquote><p>The lecture presents an explanation of the skip-gram model whereas the CBOW one is left for homework. I will give a solution to it in my next article.</p><p>If you want to have a better understanding of the <em>word2vec</em> model, I would recommend briefly going through <a href="http://web.stanford.edu/class/cs224n/">Stanford’s NLP course</a>. Let me know if you have any questions so I can assist you.</p><p><a href="https://medium.com/p/ed368af28d73/edit">In the next part</a>, I will give solutions to <a href="https://docs.google.com/document/d/1CpBvivgmo_4sMmnlWqjFAXTXKa_bI9dJVSQLPZIu7Vg/edit">Assignment 1</a> of this course. Hope you enjoy the series :)</p><h4>Thank you for the reading. If you enjoyed the article, give it some claps 👏 . Hope you have a great day!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57dc73920915" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>