<?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[Paper Club - Medium]]></title>
        <description><![CDATA[Summaries, thoughts, and questions about foundational and cutting-edge academic papers about deep learning. - Medium]]></description>
        <link>https://medium.com/paper-club?source=rss----754aaa9b86fd---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Paper Club - Medium</title>
            <link>https://medium.com/paper-club?source=rss----754aaa9b86fd---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 00:04:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/paper-club" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How a Self-Taught Programmer Taught Himself Machine Learning in 10 Weeks]]></title>
            <link>https://medium.com/paper-club/machine-learning-engineering-in-10-weeks-a9af8c739c6e?source=rss----754aaa9b86fd---4</link>
            <guid isPermaLink="false">https://medium.com/p/a9af8c739c6e</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Tiger Shen]]></dc:creator>
            <pubDate>Wed, 27 Feb 2019 12:16:05 GMT</pubDate>
            <atom:updated>2019-03-05T15:36:59.335Z</atom:updated>
            <content:encoded><![CDATA[<h3>Context</h3><p>Paper Club began in 2017 as a group of friends with a shared interest in the trendy fields of AI and deep learning. Over the next year and a half, we eagerly dove into the latest research on neural network theory and architectures. We took courses, read papers, and fiddled around with <a href="http://kaggle.com/">Kaggle</a> competitions.</p><p>As we continued down this path, some concerning patterns emerged:</p><ul><li>Seemingly every few months, the field would change dramatically. New results would be published that beat the state-of-the art and the authors would propose several reasons why. Then, sooner than later, counter-evidence would emerge and chaos would ensue. It didn’t help matters that the rigor and reproducibility of most research left a lot to be desired. Keeping up with everything felt like a big game of whack-a-mole. This may be the spirit of academia and research, but for a group of relative beginners, it felt like an inefficient learning path, to say the least.</li><li>For the few universally-accepted pieces of knowledge we were able to extract, retention became an issue. It felt like I had been dropped into the middle of a story and had nothing to anchor the new plot points to. This experience felt eerily familiar to me as a self-taught web developer who eventually learned the underlying computer science fundamentals. The fancy new stuff was exciting, but without a foundation to build upon, there was a definite ceiling to how much I could learn and retain.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9mtSdkptKT2DUoH-w6QggA.jpeg" /><figcaption>Deep Learning was chaos. Photo by <a href="https://unsplash.com/photos/fsgyO8vF7do?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Peter Nguyen</a> on <a href="https://unsplash.com/search/photos/chaos?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>And so, last Fall, we set out as a group to address this issue by taking a step backwards and learning “classical” machine learning together.</p><p>As a general rule, the algorithms that fall under “classical” machine learning are older and more interpretable than deep neural networks. My previous assumption was that these tradeoffs resulted in a massive performance downgrade — after all, why else would people be so excited about neural networks?</p><p>It turns out that for all but the most cutting-edge workloads (think Google/Facebook scale), classical machine learning algorithms are deployed very widely and to great effect. And after spending countless hours debugging neural networks where the issue could be in one of a million places with no indication of where to begin, I could certainly see the appeal of an interpretable and fast, if slightly-worse-on-paper, model.</p><h3>Planned Curriculum</h3><p>After doing some light research, we decided that we would pull from two primary machine learning resources:</p><ul><li>Andrew Ng’s Machine Learning Coursera course [<strong>coursera</strong>]: <a href="https://www.coursera.org/learn/machine-learning">https://www.coursera.org/learn/machine-learning</a></li><li>Hands-On Machine Learning book [<strong>hands-on</strong>]: <a href="https://www.amazon.com/Hands-Machine-Learning-Scikit-Learn-TensorFlow/dp/1491962291">https://www.amazon.com/Hands-Machine-Learning-Scikit-Learn-TensorFlow/dp/1491962291</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*L_w5wdlY_Al4YtbTp3pvSQ.jpeg" /></figure><p>as well as a few one-off pieces [<strong>misc</strong>]. Having had the most previous machine learning experience, Jason Benn was our spirit guide on this journey. The original plan looked like this:</p><ul><li>Chapter 2 End-to-End Machine Learning Project <strong>[hands-on]</strong></li><li>Chapter 3 Classification (precision/recall, multiclass) <strong>[hands-on]</strong></li><li>Text feature extraction (from sklearn docs) <strong>[misc]</strong></li><li>Chapter 4 Training Models (linear/logistic regression, regularization) <strong>[hands-on]</strong></li><li>Advice for Applying Machine Learning <strong>[coursera]</strong></li><li>Chapter 5 SVMs (plus kernels) <strong>[hands-on]</strong></li><li>Chapter 6 Decision Trees (basics) <strong>[hands-on]</strong></li><li>Chapter 7 Ensemble Learning and Random Forests (xgboost, RandomForest) <strong>[hands-on]</strong></li><li>Chapter 8 Dimensionality Reduction (PCA, t-SNE, LDA) <strong>[hands-on]</strong></li><li>Machine Learning System Design <strong>[hands-on]</strong></li><li>(Google) Best Practices for ML Engineering <strong>[misc]</strong></li></ul><p>Jason picked these pieces to optimize for “real-world practicality and covering lots of interesting ground quickly”.</p><h3>Completed Curriculum</h3><p>We ended up deviating slightly from the original plan. This is a summary of the curriculum we went through. My learnings are split between <a href="http://tigerthinks.com/2018/07/18/mle-in-ten-parts/">notes</a> and <a href="http://tigerthinks.com/anki">flashcards</a>, as I was experimenting with different learning techniques throughout the course.</p><p><strong>Chapter 2 End-to-End Machine Learning Project </strong>[hands-on]</p><p>This was a high-level overview of the eight steps of a machine learning project:</p><ol><li>Look at the big picture</li><li>Get the data</li><li>Discover and visualize the data to gain insights</li><li>Prepare the data for ML algorithms</li><li>Select a model and train it</li><li>Fine-tune your model</li><li>Present your solution</li><li>Launch, monitor, and maintain your system</li></ol><p>It set the stage for the rest of the curriculum.</p><p><strong>Chapter 3 Classification (precision/recall, multiclass) </strong>[hands-on]</p><p>Classification is one of the two main types of machine learning tasks (regression being the other). This chapter walked through the creation and, more importantly, evaluation of classifiers trained to identify handwritten digits.</p><p><strong>Chapter 4 Training Models (linear/logistic regression, regularization) </strong>[hands-on]</p><p>This chapter of Hands-On ML covers linear and logistic regression, a simple but <a href="https://twitter.com/ShalitUri/status/1009534668880928769">extremely powerful</a> set of tools for dealing with continuous data.</p><p><strong>Text feature extraction (from sklearn docs) </strong>[misc]</p><p>Here, we took a quick break in between the super-basic machine learning techniques and slightly more technical ones. ML algorithms only take numbers as inputs, but some of the most useful ML tasks start with a text dataset. Understanding how to transform text into numerical features using techniques like bags-of-words and TF-IDF opens up all of these tasks at a low cost.</p><p><strong>Chapter 6 Decision Trees (basics) </strong>[hands-on]</p><p>Covering decision trees, mainly as a stepping stone for random forest; in practice, random forests are preferred in almost every situation, but you don’t want to be the person who can’t see the forest for the trees.</p><p><strong>Chapter 7 Ensemble Learning and Random Forests (xgboost, RandomForest) </strong>[hands-on]</p><p>In Jason’s humble opinion, the most useful set of machine learning techniques today. This chapter covers ensemble learning methods where multiple models are trained slightly differently on the same task and are aggregated to make a final prediction. These include gradient- and adaptive-boosted models as well as the aforementioned random forests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1UNQo12GNF1qC6zr3xckGw.png" /></figure><p><strong>Chapter 8 Dimensionality Reduction (PCA, t-SNE, LDA) + AirBNB paper </strong>[hands-on]</p><p>The <a href="https://en.wikipedia.org/wiki/Curse_of_dimensionality">curse of dimensionality </a>comes up over and over again for even the most slightly non-trivial machine learning problems. Being able to recognize and address it is a cheap way to bootstrap faster training speeds and better model performance.</p><p>James also found this <a href="https://arxiv.org/abs/1810.09591">AirBNB paper</a> about how they applied deep learning to their organization, and it was compelling to read through and discuss with the added context of our machine learning studies.</p><p><strong>Chapter 5 SVMs (plus kernels) </strong>[hands-on]</p><p>After some back-and-forth about the present-day usefulness of Support Vector Machines, we decided to go ahead and spend a week on this chapter. It turned out that, while backed by some interesting concepts, they seem to be too inflexible and easily replaced by other techniques.</p><p><strong>(Google) Best Practices for ML Engineering + implementation </strong>[misc]</p><p>For this section, we took a read through Google’s published <a href="https://developers.google.com/machine-learning/guides/rules-of-ml/">Rules of Machine Learning</a> guide and each chose a pet task to implement one of the machine learning techniques we’d learned about. This was a chance to tie a bow around the last ~10 weeks of learning.</p><p>Notably, you’ll see that we decided to drop the Andrew Ng Coursera course from the original curriculum. After trying to get into the few lessons we had planned, it turned out that the lack of tree-based methods and the use of Octave instead of Python in the class were not worth the extra effort.</p><h3>Takeaways</h3><p>If you recall, the two issues we had with deep learning that prompted our foray into classical machine learning were: a) constantly-changing best practices and results, leading to b) an inability for beginners to accurately judge useful and practical information.</p><p>I’m happy to report that these few months more than adequately addressed those concerns.</p><p>It’s hard to overstate how refreshing it was to work with the SciKit-Learn library after spending so much time wrestling with scattered and poorly integrated deep learning infrastructure. The Pipeline and Estimator abstractions are breathtakingly beautiful. It turned out that for a majority of workloads, most of the effort was in the data exploration and preparation steps, and a mere `estimator.fit(X_train, Y_train)` was all that it took to get results and iterate.</p><p>Taking the pulse of machine learning practitioners online and in-person, I get the sense that random forests or gradient boosted models are a perfectly acceptable, and often preferred, model choice for 90%+ of real-life workloads. The speed and interpretability benefits are significant, especially when you can take the opportunity cost of fiddling with a poorly-defined deep learning architecture and apply it to augment and improve your dataset (which is much, much more likely to lead to better results).</p><p>Bottom line is, I feel like a much more confident and prepared machine learning <em>practitioner</em> with these tools in my toolbox.</p><h3>Suggested Curriculum</h3><p>So, if I were to do it all over again, what would I do differently? Or — if you are also someone who got caught up in the deep learning craze and is interested in putting down stronger machine learning roots, what path would I suggest?</p><p>In general, I’m pleased with the amount of ground we covered, as well as the outcome. But as tends to happen with these sorts of things, our FOMO got the best of us and a lot of fluff made its way into the study plan (this is not inherently bad! But you should choose your own fluff).</p><p>As a rule, I would make the curriculum much more practice-heavy, replacing less-useful theory pieces like SVMs and dimensionality reduction with opportunities to actually use those techniques. This outline includes the highest-value chapters in Hands-on ML, and marks explicit time to apply your new knowledge on Kaggle:</p><ul><li>Chapter 2 End-to-End Machine Learning Project</li><li>Chapter 3 Classification (precision/recall, multiclass)</li><li>Chapter 4 Training Models (linear/logistic regression, regularization)</li><li>Kaggle competition submission with logistic regression</li><li>Chapter 6 Decision Trees (basics)</li><li>Chapter 7 Ensemble Learning and Random Forests (xgboost, RandomForest)</li><li>Kaggle competition submission with Random Forest</li><li>Kaggle competition submission with gradient boosting</li><li>Your own project!</li></ul><p>In the course of working on the Kaggle competitions, you will invariably stumble upon gaps in your knowledge or interesting sidebars to pursue; these will inherently be higher-value than any other prescriptive assignments that are laid out for you.</p><p>I would suggest choosing completed Kaggle competitions, since those are more likely to have published high-performing approaches which you can compare your own solution to.</p><p>Finally, for “your own project”, I would start with <a href="https://towardsdatascience.com/the-cold-start-problem-how-to-build-your-machine-learning-portfolio-6718b4ae83e9">Eduoard Harris’s advice</a>: build a project with <strong>an interesting dataset </strong>that <strong>took obvious effort to collect</strong>, and make it as <strong>visually impactful</strong> as possible.</p><p>Cheers, and may your models always converge!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9af8c739c6e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paper-club/machine-learning-engineering-in-10-weeks-a9af8c739c6e">How a Self-Taught Programmer Taught Himself Machine Learning in 10 Weeks</a> was originally published in <a href="https://medium.com/paper-club">Paper Club</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An algorithm for human deceit]]></title>
            <link>https://medium.com/paper-club/an-algorithm-for-human-deceit-3794b310a0?source=rss----754aaa9b86fd---4</link>
            <guid isPermaLink="false">https://medium.com/p/3794b310a0</guid>
            <category><![CDATA[probabilistic-programming]]></category>
            <category><![CDATA[inferential-statistics]]></category>
            <category><![CDATA[bayesian-machine-learning]]></category>
            <category><![CDATA[bayesian-statistics]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[James Vanneman]]></dc:creator>
            <pubDate>Mon, 23 Jul 2018 21:55:23 GMT</pubDate>
            <atom:updated>2018-07-23T22:57:17.783Z</atom:updated>
            <content:encoded><![CDATA[<h3>Background</h3><p><a href="https://medium.com/paper-club"><em>Paper club</em></a> has been studying ML for the last year and a half<em>, </em>with a focus lately on bayesian machine learning. This post is a collaborative result from several pairing sessions with <a href="https://medium.com/@regit">Tiger</a>, learning <a href="http://pyro.ai/">pyro</a> and variational methods. It is based off of the excellent <a href="https://github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/blob/master/Chapter2_MorePyMC/Ch2_MorePyMC_PyMC3.ipynb">bayesian methods for hackers example</a>, using variational inference instead of markov chain monte carlo. The full notebook can be found on <a href="https://drive.google.com/file/d/1CZR_PLTJlCaEqMFtPh7Yp77l5AbEKXMT/view?usp=sharing">google’s colab environment</a> or <a href="https://github.com/jvans1/bayesian_machine_learning/blob/master/An%20Algorithm%20of%20Human%20Deceit.ipynb">on github</a>.</p><h3>The Algorithm</h3><p>Let’s say we’re teaching a course and want to estimate how many students cheat on an exam. Obviously, if you simply ask people if they cheated, they will say no. A better algorithm, quoted from bayesian methods for hackers, is defined as:</p><blockquote>In the interview process for each student, the student flips a coin, hidden from the interviewer. The student agrees to answer honestly if the coin comes up heads. Otherwise, if the coin comes up tails, the student (secretly) flips the coin again, and answers “Yes, I did cheat” if the coin flip lands heads, and “No, I did not cheat”, if the coin flip lands tails. This way, the interviewer does not know if a “Yes” was the result of a guilty plea, or a Heads on a second coin toss. Thus privacy is preserved and the researchers receive honest answers.</blockquote><p>So in a pretty clever way, we’re encouraging honesty amongst our students, at the expense of noise in our data. We can expect roughly 50% of our data to be noise. What we need now is a way to model the percentage of students who cheated, while accounting for the noise.</p><h3>Variational Inference</h3><p>For a more in depth post on variational inference(VI), I highly recommend <a href="https://blog.evjang.com/2016/08/variational-bayes.html">Eric Jang’s post</a> on the subject. The basic idea is that we have some unknown distribution P(Z|X) which is the true distribution of our model given our data. In most cases we can’t analytically calculate this distribution so we resort to approximation methods to do it for us. VI is one method that accomplishes this. We want to create a second, known distribution Q(z), and move the parameters of this distribution closer to P(Z|X). “closer” is defined by minimizing the KL divergence of the two distributions. There are some important caveats and tradeoffs to VI and you should really go read Eric’s post, but the basic idea is to move Q(z) so that it approximates P(Z|X).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*YVFAbC7DgfAj94-0TRt8IQ.png" /><figcaption>P(Z|X) is intractable, we approximate it with Q(z)</figcaption></figure><p>By calculating the loss(KL divergence) between P(Z|X) and Q(z), we learn how to update Q(z)’s parameters so that the loss decreases at the next step, and Q becomes a better approximation.</p><p>A key point to understand here, is that while we can’t calculate the exact formula for P(Z|X), we can describe the density function in code, which VI will use for the loss.</p><h3>Bernoulli Model</h3><p>The first thing we want to do to model our data is choose a distribution from which our observations are drawn. A Bernoulli distribution is good at representing binary outcomes so that’s a good place to start. Assigning 1 to cheated, and 0 to didn’t cheat, the distribution would look like this if 40% of students said they cheated:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*J6OD90H-r_JFpHBOQVOsbg.png" /></figure><h4>Model</h4><p>In code that would look something like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YxiXngEGgEGu9Oc-koEFBg.png" /></figure><p>This is sampling from a Bernoulli distribution with <em>p = probability_of_true_answer</em>, and incorporating our data with the obs=data[i] keyword. This is how we’re going to calculate our loss. If our data has [1,1,1,1], for 4 yes answers, and our <em>probability_of_true_answer </em>is really low 1%, our model is going to realize that 1% is unlikely the true value and adjust accordingly.</p><p>So how do we model <em>probability_of_true_answer? </em>A student will say “yes” they cheated under two different conditions.</p><p>Condition 1: They flipped heads on the first flip, and they did actually cheat on the exam(true cheater)</p><p>Condition 2: They flipped tails on the first flip and heads on the second(noise)</p><p>If we have prior beliefs about how many students cheated, now would be the time reflect that in our model. In our case, let’s say we really have no idea. We’ll model our ignorance by using a uniform distribution from 0 to 1. We can combine conditions 1 and 2, and our prior ignorance of the true cheating frequency in this code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J3uLbFP0qsLTSfdXy1awlg.png" /><figcaption>pyro model for cheating frequency</figcaption></figure><p>This model succinctly describes our cheating algorithm.</p><h4>Guide</h4><p>Let’s turn our attention to Q(z). This is where the learning actually happens and there’s a few key points you have to understand about pyro in order to make the guide work properly.</p><ol><li><strong>The guide trains learnable parameters</strong>. In the guide, we want to register the parameters with pyro that we want it to train. When the model is done training, we’ll grab the updated values and use them to plot our posterior.</li><li><strong>Pyro uses a name matching system</strong>, so any “pyro.sample” that appears in the model(e.g. “cheating_frequency”), has to match the name of a “pyro.sample” in the guide. The one exception to this is any sample that incorporates data, line 14 in our example, doesn’t have a matching “sample” in the guide.</li><li><strong>The distributions don’t have to be the same</strong>. In the case of a uniform distribution in the model, it doesn’t really make sense to have a uniform distribution in the guide. The point of the guide is to <em>learn</em> parameters to its distributions, such that it fits the data better. A uniform distribution doesn’t have learnable parameters.</li><li><strong>A model’s distribution must have non-zero densities for all possible x values in a guide’s matching distribution. </strong>This one threw me off for a while and is pretty critical to creating a working model. Pyro uses the model to calculate the log probability of a specific value occurring and uses this result to calculate the loss of our guide. Let’s say we make a bad choice for our guide’s “cheating_frequency” distribution and choose Normal(0, 1). During training, we’ll sample from this distribution an x value of say, 1.5. The probability of this value occurring in a Uniform(0, 1) distribution is 0, and log(0) is infinity. Our model will start spewing infinity as the loss and won’t be able to learn. A good choice of a matching distribution is a Beta distribution, since it’s between 0 and 1, and has non-zero values in that range.</li></ol><p>A beta distribution is described by two parameters, alpha and beta. Here are some plots for different values of those parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*3E70wXw_sADe6IdQf281Uw.gif" /></figure><p>We want our guide to learn good values of alpha and beta so Q(z) comes close to representing our intractable distribution. With these pieces in mind, we get our guide function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PTZafk7XQB2WrUmrkEqijA.png" /></figure><p>It’s important to remember that there are mathematical constraints on these distributions. Alpha and beta must both be positive for this distribution to make sense. Applying these constraints as an argument is an important step to ensuring that our model adheres to mathematical reality.</p><h4>Putting it all together</h4><p>Our sample dataset will include 35 “yes” answers, and 65 “no” answers. We’ll run our model for 5000 steps to learn alpha and beta. As we learn alpha and beta, we can compute the cheating frequency mean as well as the standard deviation with the following formula:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*krmH6WPPd_m1g9Dlu-CKoQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZVIajQY2ePpvlihqtW4o1w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XPYY65L8dBBejwDbr7eYjQ.png" /><figcaption>Output of the last 400 steps</figcaption></figure><p>So we get a mean frequency of 21.4% with a standard deviation of 0.084. We’ve learned a beta distribution, Q(z), to describe cheating frequency. Plotting this distribution gives us:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R5-4y9LZj-R61zUtI3WQwA.png" /></figure><p>Let’s think about this intuitively and see if it makes sense. We expect around 50 responses to be intentionally false, either yes or no. Of those 50 false responses, about 25 will say yes. This means that of the 50 responses that were supposed to be honest, we got about 10 “yes, I cheated” answers. 10 / 50 = 20% which is on par with our mean.</p><p>At this point you might be asking yourself what is the point of using VI to solve this? It was pretty straightforward to calculate 20% analytically. Using bayesian techniques here allows us to see the <em>distribution </em>of probabilities.</p><p>How confident are we that the percentage of cheaters is 20%? How likely is it to be more or less? How likely is it that we had 0 cheaters? The distribution of values allows us to answers these types of questions. The wider a distribution, the less confident we are in the mean. In our case our distribution is relatively wide, so saying 20% of the students cheated is a misinformed judgement. We can pretty sure that the proportion of cheaters is above zero, but there’s a large range of possible values it could take on so any further conclusions would be ill-advised.</p><h3>Binomial model</h3><p>We can also choose to use a binomial distribution. Instead of saying that there is a 50% chance of an honest answer, let’s also simulate the coin flipping as described by the algorithm. Since a binomial distribution is just bernoulli distribution with N = len(data), we can easily translate the above model to use a bernoulli. The few changes we make are using “expand” to sample multiple values, 1 for each student, and summing the proportion of true answers to pass as our observation to the binomial model:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DfJ1zl0MNc6uWstkhMGcag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KE44r730qMrxjigmmWO_GA.png" /></figure><p>Simulating the coin flips, and saying there is a 50 % chance of an honest answer are semantically the same, but we’re adding a small amount of variance in our model. Notice that the standard deviation as the end is 0.091, which is somewhat larger than 0.084 of the previous model. Plotting this graph, we can see that our uncertainty is a little larger(slightly wider distribution)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YEVvbI84-D-_eBHbJQ_-Rw.png" /></figure><h3>Conclusion</h3><p>VI is a powerful technique. It allows you to approximate otherwise intractable distributions and gives you insight into the confidence of our estimates. There can be multiple correct ways to model the same distribution and one isn’t necessarily any better or more correct than the other.<em> </em>Variational methods turned out to be some of the most challenging work we’ve encountered. Pyro is a great library but it assumes a lot of knowledge of the intricacies of VI that can make it difficult to approach. If you’re new to VI and want to work with pyro, I recommend <a href="https://arxiv.org/pdf/1301.1299.pdf">reading papers</a> and spending time understanding the background before digging into the code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3794b310a0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paper-club/an-algorithm-for-human-deceit-3794b310a0">An algorithm for human deceit</a> was originally published in <a href="https://medium.com/paper-club">Paper Club</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Pyro’s Model and Guide: A Love Story]]></title>
            <link>https://medium.com/paper-club/understanding-pyros-model-and-guide-a-love-story-7f3aa0603886?source=rss----754aaa9b86fd---4</link>
            <guid isPermaLink="false">https://medium.com/p/7f3aa0603886</guid>
            <category><![CDATA[probabilistic-programming]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[pyro]]></category>
            <dc:creator><![CDATA[Tiger Shen]]></dc:creator>
            <pubDate>Wed, 20 Jun 2018 12:41:00 GMT</pubDate>
            <atom:updated>2018-06-20T16:44:58.838Z</atom:updated>
            <content:encoded><![CDATA[<p><em>For background on why all of a sudden there’s Bayesian content on this blog, see </em><a href="https://medium.com/paper-club/where-have-we-been-75c229d42acc"><em>here</em></a><em>.</em></p><h3>Rambling Introduction 🤦</h3><p>After wrapping up <a href="https://github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers">Bayesian Methods for Hackers</a> (9/10 would recommend), I’ve been working with Uber’s <a href="http://pyro.ai/">Pyro</a> library for the past few weeks. Pyro is a deep universal probabilistic programming language build on top of the PyTorch deep learning framework. Sounds fancy, but don’t let that scare you! My experience has been two parts challenging, one part fun, and I wouldn’t have it any other way.</p><p>One of the biggest obstacles has been the relative youth of the library. Pyro was open-sourced in December 2017 and is built on PyTorch which was itself released in October 2016. On top of that, probabilistic programming and Bayesian methods have always been relatively niche and even in the past few years have taken a backseat to more “mainstream” deep learning like CNNs and RNNs. Thus, the existing literature and tutorials are mainly written by and for academic, math-y types — efficient for the important folks, harder to parse for newbies like me.</p><p>As I sit on some of these concepts I’m going to try and re-explain them in my own words, to solidify my own understanding and hopefully help fill a gap in existing documentation.</p><p>This post only assumes basic knowledge of how probability distributions work (<a href="https://www.zinkov.com/posts/2015-06-09-where-priors-come-from/">this</a> might be a decent starting point if you want a refresher or reference point). I will walk you through all of the Pyro parts, with the disclaimer that I am not (yet) a complete expert.</p><h3>Ridiculous Analogy 🙄</h3><p>Let’s start with the most immediate and important new concept Pyro introduced to me: <strong>the guide</strong>.</p><p>To reason about the guide, you must start with a <strong>model</strong>. You can think of the model as an arbitrary python function.</p><p>But to make our initial neural connection, we’ll be using another definition: the smoking hot swimsuit model, say, Kate Upton.</p><p>To understand the guide, think up this scenario:</p><blockquote>The guide is madly in love with the model. He’s made it his life’s mission to pursue her, and he’s willing to go to the ends of the latent space to breathe the same air as her. So he follows her everywhere she goes (kinda creepy yeah but bear with me).</blockquote><blockquote>The model gets into the most exclusive clubs and parties and constantly has a security detail. In this scenario, we are paparazzi who are trying to follow the model around. The problem is, she can hop on her private jet and could be anywhere on Earth at any given time. Luckily, following her isn’t work but more like eating, drinking, and breathing for the guide. His obsession means that he is never far away from the model, chasing her wherever she goes. Even at these exclusive parties, he can be found right outside the building. And so, by simply tracking the guide we are able to get a very accurate location for the model at any given time.</blockquote><p>In practice, it might look something like this, where P(Z|X) is the model and Q(z) is the guide:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*cUMrUSWmLClDfYa9LTO8KA.png" /><figcaption>Guide approximating model (<a href="https://blog.evjang.com/2016/08/variational-bayes.html">source</a>)</figcaption></figure><p>Q is a much “simpler” Gaussian distribution than P, but it is the <em>closest possible Gaussian </em>to P. Obviously, in real life with real distributions we will aim for a closer approximation.</p><h3>Actual Content 😱</h3><p>Let’s use this concept to build a probabilistic model.</p><p>Every time James, Tiger, and Jason go to The French Laundry, they play <a href="https://en.wikipedia.org/wiki/Credit_card_roulette">credit card roulette</a> to determine who pays. This began as a form of good-natured entertainment since they’re all rational human beings who know that it should even out over time. After 20 meals, James has picked up 4 bills, Tiger has paid for 9, and Jason has been responsible for 7.</p><p>Now, Tiger can’t help but get a little bit suspicious — he’s been stuck with almost half of the tabs! And how has James only paid for 4?? He’s clearly cheating! Taking a deep breath, Tiger gathers himself and sets out to build a model to determine whether there’s foul play at hand.</p><h4>Setup</h4><p>If you’re following along at home, we’ve installed the latest versions of Pyro (<strong>0.2.1) </strong>and PyTorch <strong>(0.4.0) </strong>(see <a href="https://medium.com/paper-club/how-to-set-up-google-colab-colaboratory-for-building-pyro-models-8e51129e772a">here</a> for instructions on how to do this from scratch on a cloud GPU) and imported these packages:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d70eedb356e7a6ac00f741332a83e3a4/href">https://medium.com/media/d70eedb356e7a6ac00f741332a83e3a4/href</a></iframe><p>Performed some good Pyro hygiene:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/70fd9642fc88b478af0c4146ecf17dc5/href">https://medium.com/media/70fd9642fc88b478af0c4146ecf17dc5/href</a></iframe><p>And set up a dataset representing the number of times each person has paid:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1413f8b78a79678b1c1230e27dfc6df/href">https://medium.com/media/f1413f8b78a79678b1c1230e27dfc6df/href</a></iframe><p>What output do we want from our model? The most straightforward answer would be three probability distributions representing the chances that each person pays for a meal, given the observed data. This will help us determine whether Tiger is really being cheated out of his hard-earned funds.</p><p>A good choice for modeling probabilities is the <a href="https://en.wikipedia.org/wiki/Beta_distribution">Beta distribution</a>. In this case, we want to start off with distributions peaking around 0.33, or 1/3 chance, since this is a reasonable naive assumption for the “true” fairness of our game of credit card roulette. Parameter values of <strong>6.0 </strong>for alpha and <strong>10.0 </strong>for beta seem to do the job:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*F07F8Nt5OwhW9gna1NjiSg.png" /><figcaption>Beta distribution with hyperparameters 6 and 10</figcaption></figure><h4>Model</h4><p>We can now build our model:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42ce84b3942cdd183260379dc59c7292/href">https://medium.com/media/42ce84b3942cdd183260379dc59c7292/href</a></iframe><p>Models in Pyro are Python functions which take data as input and make use of Pyro primitives to analyze the data. Things to note about our model:</p><ul><li>pyro.sample is a Pyro primitive that creates a latent random variable. In our model, we are going to sample three “pay probabilities” from the Beta distribution representing each person’s probability of paying and give it a name of pay_probs. This will give us something like tensor([0.2091, 0.3522, 0.3726]) (without adding .expand(3).independent(1), we would only get one sample). As you’ll see later, <strong>pyro.sample statements without the obs keyword must appear in both the model and the guide.</strong></li><li>It’s unlikely that our sampled probabilities add up to 1 like we want, so we normalize pay_probs to represent the fact that they are interdependent.</li><li>pyro.iarange is a Pyro construct that provides some improved performance that acts like Python’s range and allows us to vectorize the most important piece of our model…</li><li>pyro.sample statements with the obs keyword are how we incorporate observations into our model. Here, we pass our normalized pay probabilities to a Categorical distribution,which will return samples from the set {0, 1, 2} proportional to the respective probabilities. For example, if our pay probabilities were tensor([0.25, 0.25, 0.5]) the Categorical distribution would return 0 25% of the time, 1 25% of the time, and 2 50% of the time. We then compare these samples to the observed data to train our model.</li></ul><p>“But wait!” you might be saying. “What exactly is being trained? You just hardcoded those hyperparameter values of 6 and 10!” Well, glad you asked. Enter:</p><h4>Guide</h4><p>Let’s declare our guide.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/581d6929de9451ed08ab9f9f53e637c3/href">https://medium.com/media/581d6929de9451ed08ab9f9f53e637c3/href</a></iframe><p>Keep in mind that analogy of the guide <em>following</em> the model around. The guide can be arbitrary python code just like the model, but with a few requirements:</p><ul><li><strong>Every </strong><strong>pyro.sample statement without the </strong><strong>obs keyword that appears in the model must have a corresponding </strong><strong>pyro.sample statement with the same name in the guide. </strong>We sample with the name pay_probs here to meet this requirement. <em>Note: the sample statements in the model and guide are not required to use the same distribution, but they often do.</em></li><li>There are no pyro.sample statements with the obs keyword in the guide. These are exclusive to the model.</li><li>There <em>are </em>pyro.param statements, which are exclusive to the guide. These provide differentiation for the inputs to the pay_probs sample in the guide vs. the model. These special variables are the pieces that are actually going to be trained. We declare them as vectors alphas and betas with three unique elements matching the three probability distributions we hope to see as the model’s output.</li></ul><h4>Training</h4><p><strong>IMPORTANT PARAGRAPH:</strong></p><p>We will be using a process called SVI with ELBO loss to train our model. It’s not important to understand all of the nuts and bolts at this point. At a high level, each step in the training process will take one pass through the model and incorporate the observed data. Then, it will go through the model code again, <strong>replacing each </strong><strong>pyro.sample statement with the corresponding statement from the guide. </strong>It compares the resulting distributions from the model and guide and adjusts the pyro.param values in order to get the guide closer to the model. This way, the guide will in theory follow the model around and get close enough to confidently approximate it.</p><p><em>Note: I couldn’t give you a 100% confident explanation as to why the model posterior distribution is intractable and we have to use the guide as an approximation, but I’m inclined to say it has something to do with the curse of dimensionality.</em></p><p>We’ll start with a quick function to print our training progress:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5cd4fa4eb188fd70616e088cb783248f/href">https://medium.com/media/5cd4fa4eb188fd70616e088cb783248f/href</a></iframe><p>Nothing that special here. The most notable thing is the use of alphas = pyro.param(&quot;alphas&quot;) to query the state of a parameter in the currently-training Pyro model.</p><p>And our training loop:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ab962a6a7e2e65fb9c3412a1e6feb2e/href">https://medium.com/media/6ab962a6a7e2e65fb9c3412a1e6feb2e/href</a></iframe><p>We’re using the Adam optimizer here with a super scientific magical learning rate of 0.0005. If you’re unfamiliar with Adam, don’t worry. I’m no expert in optimization functions, but Just Use Adam ™ hasn’t failed me yet.</p><p>Pay attention to the interface for the SVI process: we pass it our model function, our guide function, and our optimizer, with a loss function of Trace_ELBO (no need to completely understand that for now). These are all of the components we need for successful training.</p><p>Then we just perform a given number of steps and print progress as we go. Whee!</p><h4>Validation</h4><p>This is an abbreviated version of the output we expect to see:</p><pre>[ 0 | probability Tiger pays: 0.333 +/- 0.10 | probability Jason pays: 0.333 +/- 0.10 | probability James pays: 0.333 +/- 0.10 ] <br>...</pre><pre>[ 700 | probability Tiger pays: 0.368 +/- 0.11 | probability Jason pays: 0.343 +/- 0.10 | probability James pays: 0.288 +/- 0.10 ] <br>...</pre><pre>[ 2500 | probability Tiger pays: 0.377 +/- 0.10 | probability Jason pays: 0.340 +/- 0.10 | probability James pays: 0.283 +/- 0.10 ]</pre><p>As you can see, our normalized initial probabilities start where we expect them, giving each person a 1/3 chance of paying for the meal. As the model trains, we see the probabilities moving in the correct direction. Eventually they stabilize ~ 0.380, ~ 0.340, and ~ 0.280, respectively.</p><p>From 10000 samples, in graph form, Tiger’s distribution:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*SS8_g1IJ0UgCD_xgw6tAwg.png" /></figure><p>Jason’s distribution:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*V9EOB_cTB8TYeg8mzeU_XA.png" /></figure><p>James’s distribution:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*B2C7q_8Du7MYn2o7etD6Ng.png" /></figure><p>And overlayed on each other:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*I3rHj-But97-z9Aa7QlAvA.png" /></figure><h4>Conclusion</h4><p>So, is Tiger’s skepticism justified? Well, given the mean and standard deviation Pyro gives us for his final chances of paying (0.377 +/- 0.10), he should breathe a bit easier…for now. Over a third of this distribution lies at or below 0.333 (completely even chances of paying), which is well within the range of outcomes.</p><p>What if the group ate out 20 more times and got the same proportion of tabs paid? Do the model’s answers change? Do the model’s certainty in its answers change? What if they had half as many trials? Try and play around with different formulations of this problem and see what you find!</p><p><em>Special thanks to @jpchen on the Pyro forum for helping me work through some of the nuances of using Pyro for this example: </em><a href="https://forum.pyro.ai/t/svi-part1-readjusted-with-multinomial-instead-of-bernoulli-doesnt-work/192">https://forum.pyro.ai/t/svi-part1-readjusted-with-multinomial-instead-of-bernoulli-doesnt-work/192</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f3aa0603886" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paper-club/understanding-pyros-model-and-guide-a-love-story-7f3aa0603886">Understanding Pyro’s Model and Guide: A Love Story</a> was originally published in <a href="https://medium.com/paper-club">Paper Club</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Set Up Google Colab/Colaboratory For Building Pyro Models]]></title>
            <link>https://medium.com/paper-club/how-to-set-up-google-colab-colaboratory-for-building-pyro-models-8e51129e772a?source=rss----754aaa9b86fd---4</link>
            <guid isPermaLink="false">https://medium.com/p/8e51129e772a</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[probabilistic-programming]]></category>
            <category><![CDATA[pyro]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Tiger Shen]]></dc:creator>
            <pubDate>Tue, 19 Jun 2018 01:14:27 GMT</pubDate>
            <atom:updated>2018-06-19T01:14:26.626Z</atom:updated>
            <content:encoded><![CDATA[<p>Google’s <a href="http://colab.research.google.com/">Colab</a> is basically Google Docs for interactive, runnable Jupyter Notebooks, and it is a fantastic resource for playing around with machine learning models. It comes with great sharing and collaboration features and even a free GPU runtime!</p><p>However, the backend it runs on only comes with a subset of the dependencies needed to run <a href="http://pyro.ai/">Pyro</a> models. I’m going to quickly run through the <strong>steps to set up Pyro in a Colab notebook</strong>. If you already know how to use Colab and just want the setup code for Pyro, skip to <strong>Install and import dependencies.</strong></p><h4>Sign up for Colab</h4><p>Anyone with a Google Drive account can sign up for Colab by heading to <a href="http://colab.research.google.com/">colab.research.google.com </a>and following the listed instructions.</p><h4>Create a new notebook</h4><p><em>File -&gt; New Notebook. </em>Either Python 2 or 3 will work, but I would recommend Python 3 (that’s what the rest of this tutorial will be using)</p><h4>Set up the GPU runtime</h4><p><em>Runtime -&gt; Change runtime type -&gt; Hardware Accelerator -&gt; GPU. </em>Free GPU cycles! 😍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*b7rQHwgyl4qnvK-yWPZmoQ.png" /></figure><h4>Install and import dependencies</h4><p>In the first code cell of your notebook, install PyTorch and Pyro. Those exclamation points tell Jupyter/Colab that the pip3 commands are meant to be executed as shell commands and not Python code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37e4ba00f8abf7d8ae01369b72e7375d/href">https://medium.com/media/37e4ba00f8abf7d8ae01369b72e7375d/href</a></iframe><h4>Test it out</h4><p>Try running the basic Pyro model from the <a href="http://pyro.ai/examples/svi_part_i.html">SVI Part I</a> tutorial:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b48261d862da6adacee4ee7e9223fdb9/href">https://medium.com/media/b48261d862da6adacee4ee7e9223fdb9/href</a></iframe><p>You should get some output about the fairness of a coin’s flips.</p><p>That’s that! Happy deep universal probabilistic programming!</p><p>The full code for a working Pyro model with Python 3 on Colab can be found <a href="https://colab.research.google.com/drive/1sn56GrvB6Xpy8XRLMinECVdnL7MAl2X1">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e51129e772a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paper-club/how-to-set-up-google-colab-colaboratory-for-building-pyro-models-8e51129e772a">How To Set Up Google Colab/Colaboratory For Building Pyro Models</a> was originally published in <a href="https://medium.com/paper-club">Paper Club</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Analytical Bayesian Inference with Conjugate Priors]]></title>
            <link>https://medium.com/paper-club/analytical-bayesian-inference-with-conjugate-priors-4a1d75ca799b?source=rss----754aaa9b86fd---4</link>
            <guid isPermaLink="false">https://medium.com/p/4a1d75ca799b</guid>
            <category><![CDATA[bayesian-statistics]]></category>
            <category><![CDATA[bayesian-machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[bayesian]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[James Vanneman]]></dc:creator>
            <pubDate>Sun, 06 May 2018 16:22:17 GMT</pubDate>
            <atom:updated>2018-05-06T16:57:32.242Z</atom:updated>
            <content:encoded><![CDATA[<p>I have been working a lot with <a href="http://pyro.ai/">pyro</a> lately, trying to wrap my head around variational methods and statistical machine learning. Variational bayes(VB) methods are an excellent way to solve otherwise intractable problems and have revolutionized the field of statistical machine learning. Before VB methods, using bayesian inference required careful choices of distributions such that inference was analytically tractable. In order to build some intuition around VB, I’ll walk throughs some of the analytically tractable approaches to bayesian inference. Full code for this post can be seen <a href="https://github.com/jvans1/bayesian_machine_learning/blob/master/Conjugate%20Priors.ipynb">here</a></p><h3>Outline For Creating a Bayesian Model</h3><p>There are four main steps to creating a bayesian model.</p><ol><li>Define a model that makes the <em>most sense</em> for how the data might have been created</li><li>Define a prior, e.g. define the parameters of the model in terms of a distribution</li><li>Use observations to construct a likelihood function.</li><li>Combine the likelihood and the prior to create a posterior distribution</li></ol><h3>Step 1: Define a model</h3><p>John just opened a bakery and needs our help making predictions around how many pies he’ll sell in a day. A <a href="https://en.wikipedia.org/wiki/Poisson_distribution">poisson distribution</a> is a good starting point because it is a discrete probability distribution that expresses the probability of a fixed number of events occurring in a specific time interval. The poisson distribution takes a parameter λ. The probability of getting a specific data point can be represented by fixing λ in the equation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*IkP0Ml6uSLXwHKYZUtEipg.png" /></figure><p>Now what’s a good value for λ? Well, a really nice property of the poisson distribution is that λ represents the mean. John has a general idea that his mean will be around 4. Plugging this value in for λ gives the following pmf.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XDr4-vc-1MqMbzutFufT4A.png" /><figcaption>histogram for poisson λ = 4</figcaption></figure><h3>Step 2: Define a prior</h3><p>The next step is to define the parameter of our model λ, as a distribution.</p><p>John’s best guess is a mean of 4(μ = 4), but he isn’t very confident in his estimate so we’ll reflect that confidence in our prior. We’ll choose a gamma distribution to represent the mean, why that’s a good choice will become apparent shortly! We want to reflect our prior belief that the actual mean is <em>around</em> 4, so we’ll choose parameters for the gamma distribution, shape(𝑘) and scale(𝜃), such that the mean of our gamma distribution is 4.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*M68qds5xLUfv5D64geSjdg.png" /><figcaption>Definition of Gamma Distribution (𝚪 is the gamma function)</figcaption></figure><p>For now we choose 𝑘 = 4 and 𝜃 = 1. Because μ = 𝑘𝜃 for the gamma distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*Wxetwe6X99lHkgXUEh0Rag.png" /><figcaption>gamma distribution with 𝑘 = 4 and 𝜃 = 1</figcaption></figure><p>Plotting this gamma distribution</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GVBaWLpG3USE1YQAIVIPYQ.png" /><figcaption>plot of gamma distribution for 𝑘 = 4 and 𝜃 = 1</figcaption></figure><p>Now the choice for 𝑘 = 4 and 𝜃 = 1 isn’t entirely arbitrary. We want to choose values here that encode our uncertainty in our guess. If we are very uncertain, we’ll choose values that make this distribution wider, reflecting this uncertainty.</p><h3>Step 3: Construct a likelihood function</h3><p>The likelihood function for a specific observation is 𝑃(x|λ). For multiple observations, you multiply their likelihoods together, so the likelihood becomes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*-NljVQa6Sy5mvqD82hrvCg.png" /><figcaption>likelihood for n observations</figcaption></figure><h3>Step 4: Calculate the posterior</h3><p>Now let’s use bayes theorem to calculate our posterior.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*CuuvGxg_FYCPpQLJtJhuMw.png" /><figcaption>bayes theorem</figcaption></figure><p>P(X) is a constant because the values of X are fixed to the observations. The equation reads probability of λ <em>given our observations</em> X. We can ditch the P(X) denominator term temporarily just so long as we rescale the distribution at the end. We can now say that the left hand side is <em>proportional to</em> the right hand side</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*M7NmPg7fxlGHrYlea3-Snw.png" /></figure><p>Plugging in our equations, we get a posterior distribution for λ:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*2V0Pil_rb5e04QqnlM0tmw.png" /></figure><p>For the sake of simplicity, let’s say we observe 1 day where 6 pies are purchased. This equation simplifies to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*ZYkeMBNFOd1Obh6cwWgA9Q.png" /></figure><p>ensure we re-scale the distribution by some constant C so that it integrates to 1:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*y1G5vZFFO6g-KK47MX3mWg.png" /></figure><p>and combine terms to get the posterior distribution:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/292/1*6joKAGu3MRBuyq2I1hbxlg.png" /></figure><h3>Conjugate priors</h3><p>We’ve computed our posterior for λ, but even more incredibly, we’ve landed back on a Gamma distribution! Let’s see exactly how this is the case. Remember the gamma distribution is defined as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*0OzM7LIQA97SHrzn3xJVvA.png" /></figure><p>At the beginning of this post, we somewhat arbitrarily chose values for 𝑘 and 𝜃. Now, notice that a choice of 𝑘 = 10 and 𝜃 = 0.5 gives us our posterior!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*iObwGbU7-JvqjBavpo8UPA.png" /></figure><p>which just means that in our calculation of the posterior we choose C:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*ePzyPlcrCS7IYJopz_Gu_g.png" /></figure><p>Now this wasn’t an accident, in fact it’s precisely the reason that I chose a gamma distribution as the prior. A poissoin distribution’s conjugate prior is the Gamma distribution, and whenever you choose a conjugate prior, the posterior will always be of the same form as the prior</p><p>If we step back for a moment we can see that by using a conjugate prior, we generate our posterior by <strong>updating the parameters of our prior</strong> — reflecting a new mean and confidence level, depending on the amount of observed data. As we observe more datapoints, 𝑘 and 𝜃 are updated in such a way as to shrink the width of our posterior, indicating an increased level of confidence in our distribution.</p><p>Plotting our new posterior distribution:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SvZVDhT-U3PHk4ODChOYhg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a1d75ca799b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paper-club/analytical-bayesian-inference-with-conjugate-priors-4a1d75ca799b">Analytical Bayesian Inference with Conjugate Priors</a> was originally published in <a href="https://medium.com/paper-club">Paper Club</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MUST READ: Clueless Individual Attempts to Explain Basic PyMC3 Model.]]></title>
            <link>https://medium.com/paper-club/must-read-clueless-individual-attempts-to-explain-basic-pymc3-model-9859d89d5468?source=rss----754aaa9b86fd---4</link>
            <guid isPermaLink="false">https://medium.com/p/9859d89d5468</guid>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Tiger Shen]]></dc:creator>
            <pubDate>Sun, 11 Mar 2018 19:17:09 GMT</pubDate>
            <atom:updated>2018-03-11T19:17:09.471Z</atom:updated>
            <content:encoded><![CDATA[<h3>MUST READ: Clueless Individual Attempts to Explain Basic PyMC3 Model. You Won’t Believe What Happens Next.</h3><p><em>For background on why all of a sudden there’s Bayesian content on this blog, see </em><a href="https://medium.com/paper-club/where-have-we-been-75c229d42acc"><em>here</em></a><em>.</em></p><p><em>N.B.: this isn’t meant as an introduction to Bayesian methods or PyMC3. It was originally composed as a memo for myself at ~ Ch 4 of the book Bayesian Methods for Hackers, and thus makes assumptions about concepts and knowledge up to that point. I would highly recommend the book if any of this seems interesting :)</em></p><p>There have been many many (many many many) confusing parts of PyMC3 and Bayesian modeling in my short experience with these tools and concepts. Among the most challenging has been conceptualizing how observed data is added to the model, and relating this to where the MCMC (Markov Chain Monte Carlo; <a href="https://towardsdatascience.com/a-zero-math-introduction-to-markov-chain-monte-carlo-methods-dcba889e0c50">here</a>’s the best introduction I know of) algorithm hooks in to sample from the resulting posterior distribution.</p><p>Initially, I got hung up on comparisons to mini-batch SGD (Stochastic Gradient Descent; if you’re unfamiliar with this, maybe skim <a href="http://cs231n.github.io/optimization-2/">here</a> for the basic idea) in deep neural networks. Since the majority of my exposure to machine learning has been through neural nets, this is the first example of a training process that my mind reached for. In mini-batch SGD, individual samples are fed one by one to the model, loss is calculated, and the error is backpropagated through the network as part of one sequential &quot;training step&quot;.</p><p>However, this mental model does not fit in a Bayesian context, where the construction of the item of interest and the algorithm to “discover” that item are distinct. Specifically, after the prior distribution is warped by the likelihood distribution to form the posterior, without any further action the posterior is completely opaque to us; with multiple dimensions, it becomes computationally intractable to determine a function for the posterior distribution. Contrast this to a DNN where the training process can be stopped or continued at any point and the network remains as &quot;whole&quot; as at any other point. No further steps need to be taken in order to receive output from the model.</p><p>I brought this up as part of a larger discussion in our Slack group:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*uGFlrYUrbunLDbdTu3x_hg.png" /></figure><p><a href="https://medium.com/u/582134c8954f">James Vanneman</a>&#39;s second comment set off a lightbulb for me:</p><blockquote>Just want to clarify here, the sampling in MCMC doesn’t create the posterior, your dataset does. The sampling only returns you points from your posterior.</blockquote><p>So: <strong>the posterior distribution exists after the observed data has been incorporated into the model. However, due to the curse of dimensionality this posterior is inaccessible analytically. In order to approximate the posterior and do anything useful with your model, you must perform MCMC.</strong></p><p>With this in mind, I wanted to understand the PyMC3 API for representing these actions. Let&#39;s take a look at a function from Ch 4 of Bayesian Methods for Hackers. The context for this code is the task of generating a distribution for the “true upvote ratio” of a Reddit submission, based on the observed sample of up- and down-votes for that submission. From the text:</p><blockquote>One can think of the true upvote ratio as “what is the underlying probability someone gives this submission a upvote, versus a downvote?”. So the 999 upvote/1 downvote submission probably has a true upvote ratio close to 1…but on the other hand we are much less certain about the true upvote ratio of the submission with only a single upvote. Sounds like a Bayesian problem to me.</blockquote><p>I chose this example because it is more or less the most compact practical distillation of a PyMC3 analysis you can get to.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/13853ef80a2282d8cebe71bc8666641d/href">https://medium.com/media/13853ef80a2282d8cebe71bc8666641d/href</a></iframe><p>While there are still lots of fuzzy areas, I think I have enough context to take a stab at an explanation here. There are four clear steps in this function, noted with comments in the code.</p><ol><li>Create your prior. In this case we represent our parameter of interest, the true upvote ratio of a post, and we use a Uniform distribution because we have no reliable information available by which to form a different prior. “Prior distribution” is the default designation for an initialized random variable in PyMC3.</li><li>This is the step that took the longest to click, and it wasn’t until reading James’ comment that things started to fall into place. Here we are creating a binomial variable called <em>obs</em> in our model, named by the first argument. The next argument is the number of trials in the sequence — in this case, the total number of votes. With the third argument we pass in our prior, <em>upvote_ratio</em>, as the probability of success for each trial. The fourth argument is where the magic happens. The <em>upvotes</em> variable contains the observed number of upvotes. This fixes the value of the <em>obs</em> variable in our model to the <em>upvotes</em> data. While the Uniform <em>upvote_ratio</em> represents the <strong>prior distribution</strong> of the upvote ratio, the presence of observed data turns the <em>obs</em> variable into a <strong>likelihood distribution</strong>. <br>Take for example a post with 99 upvotes and 1 downvote (N = 100). You could read this line of code as “create a binomial variable representing how well each possible number of upvotes (0–100) out of 100 total votes “explains” the observation of 99 upvotes in 100 trials.” In other other words, this distribution should model the most likely values of the bias term to produce 99/100 upvotes. This should end up being concentrated in the high 90s, with a peak at 99. This likelihood distribution combined with the prior will produce a posterior distribution over the “true” upvote ratio of the post. Note that with a Uniform prior, the likelihood equals the posterior. Think of it as combining the two by multiplying the likelihood by 1 (h/t James).</li><li>With a prior and a likelihood in place, our model now has a posterior distribution over the upvote ratio which we can sample from. The Metropolis algorithm is a nuanced (read: I have no clue what distinguishes it) implementation of MCMC. Unless the default argument is overwritten, we are going to be taking 20000 samples of the posterior landscape of our model here.</li><li>As explained in the previous chapter, it’s best practice to “burn” the first N% of your MCMC trace. This data can be very noisy as the algorithm moves towards the posterior distribution without necessarily being close or inside it yet.</li></ol><p>And voila, you now have an approximation of your posterior! Easy¹.</p><p>¹Disclaimer: actually not easy at all.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9859d89d5468" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paper-club/must-read-clueless-individual-attempts-to-explain-basic-pymc3-model-9859d89d5468">MUST READ: Clueless Individual Attempts to Explain Basic PyMC3 Model.</a> was originally published in <a href="https://medium.com/paper-club">Paper Club</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Where Have We Been?]]></title>
            <link>https://medium.com/paper-club/where-have-we-been-75c229d42acc?source=rss----754aaa9b86fd---4</link>
            <guid isPermaLink="false">https://medium.com/p/75c229d42acc</guid>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Tiger Shen]]></dc:creator>
            <pubDate>Sun, 11 Mar 2018 19:16:23 GMT</pubDate>
            <atom:updated>2018-03-11T19:16:23.446Z</atom:updated>
            <content:encoded><![CDATA[<p>This blog may have been inactive since the turn of the calendar year, but rest assured Paper Club has not!</p><p>After returning from the holidays we got together to chart a course for Paper Club in 2018 and beyond. The J’s had a blast at NIPS in December and <a href="https://medium.com/u/a1863b01eaff">Jason Benn</a> started his first professional machine learning gig at <a href="http://sourceress.com/">Sourceress</a>. We were pleased with our respective and collective 2017&#39;s in AI/ML and wanted to keep the momentum going.</p><h3>Finding Bayesian Methods</h3><p>We looked at our goals and surveyed several areas of potential interest. There is so much activity in the domain right now that analysis paralysis and FOMO are almost unavoidable. We met on a boat (long story), waded through some of this, and eventually decided to explore one of our many shared curiosities: Bayesian neural nets. There was a lot of chatter about these architectures at NIPS, we had varying levels of personal interest in Bayesian statistics as a whole (mine was quite high), and we had all seen firsthand the main problem that Bayesian nets purport to solve: interpretable confidence levels in deep learning. And so, it seemed as good a place as any to continue learning together.</p><p>Briefly and most basically, Bayesian neural nets are a class of neural net that:</p><ol><li>model parameters as distributions instead of scalar values, and</li><li>allow for architect input of prior distributions for the parameters.</li></ol><p>These two properties allow for many extensions to the capabilities of neural nets. It is a comparatively greenfield architecture with exciting possibilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*RVhvDTeWPDYEoHaArHYFRA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*JP1WjJevLUSnpOpYkcxgFQ.gif" /><figcaption>Bayesian neural net regression on this equation with different small samples, demonstrating uncertainty bounds. From <a href="http://mlg.eng.cam.ac.uk/yarin/blog_2248.html">http://mlg.eng.cam.ac.uk/yarin/blog_2248.html</a></figcaption></figure><h3>Learning Bayesian Methods</h3><p>We quickly realized a third property as it applied to our attempts to learn Bayesian NNs: they are conceptually a bigger leap from vanilla neural nets than anything we’d encountered before.</p><p>We began with Yarin Gal’s <a href="http://mlg.eng.cam.ac.uk/yarin/blog_2248.html">PhD thesis</a>. I’m sure there is immense value in these 150-odd pages, and I think we will end up returning to it, but it was very far above the level of the January version of me (and others…right guys?).</p><p>I understood about 5% of the easiest chapters of the document. Even still, this was more than enough to pique my interest: active learning, deep Bayesian reinforcement learning, medical diagnostic confidence bounds, oh my! (See <a href="http://mlg.eng.cam.ac.uk/yarin/thesis/5_applications.pdf">Chapter 5</a> for a relatively digestable summary of these applications and more) I understood the neural network-related concepts, but it was clear I’d need more background in Bayesian analysis and probabilistic programming in order to grasp the entire thesis.</p><p>The next place I looked was <a href="http://pyro.ai/">Pyro’s</a> tutorials. Pyro is a new library from Uber for “Deep Universal Probabilistic Programming”. Since I’d spent the past 9 months doing the “deep universal” thing, I figured I might be able to pick up the “probabilistic programming” part on the side as I worked through tutorials. After all, it comes second in the description so how hard can it really be?</p><p>Too hard for me, as it turned out. Dropping down one more level of simplification, I arrived at Cam Davidson-Pilon’s <a href="https://github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers">Bayesian Methods for Hackers</a> book, which had previously been shared to the group by <a href="https://medium.com/u/67c50b422a5b">Jason Morrison</a>. This book entirely focuses on Bayesian analysis and probabilistic programming, without getting into the deep learning applications. And it was just right.</p><p>The rest of the group seemed to share my appreciation for the writing style, engagingness, and overall fun of this book, so we decided to work through it together. And that’s where we’ve been! The material has been very interesting and, in my humble opinion, at the absolute perfect level of difficulty.</p><p>So here we are, with about two chapters left in that book. We have a loosely formed goal of taking what we’ve learned and working on a project with Pyro or PyMC3. Hopefully we’ll be sharing more of that and what we’re up to once we get through the book. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75c229d42acc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paper-club/where-have-we-been-75c229d42acc">Where Have We Been?</a> was originally published in <a href="https://medium.com/paper-club">Paper Club</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI Index Index]]></title>
            <link>https://medium.com/paper-club/ai-index-index-ae0e3a8083d8?source=rss----754aaa9b86fd---4</link>
            <guid isPermaLink="false">https://medium.com/p/ae0e3a8083d8</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Tiger Shen]]></dc:creator>
            <pubDate>Thu, 14 Dec 2017 03:01:30 GMT</pubDate>
            <atom:updated>2017-12-13T21:19:46.813Z</atom:updated>
            <content:encoded><![CDATA[<h4>Summarizing a summary of the state of AI</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ydd4jMFo-DsWN6dGTTEMIA.png" /></figure><p>Earlier this month a team made up of and sponsored by Stanford, MIT, OpenAI, Google, Microsoft, etc. released the <a href="http://www.aiindex.org/">AI Index</a>, a first-of-its-kind deep-dive into the trends in the Artificial Intelligence community.</p><p>It was a much-needed, sometimes surprising, mostly reassuring look at the state of ML/AI in 2017. I’m going to summarize some of my favorite parts and themes, but I would encourage you to read the report in its entirety <a href="http://cdn.aiindex.org/2017-report.pdf">here</a>. The data itself runs for 40 or so pages of size 16 font with plenty of whitespace and lots of pictures (very refreshing after reading academic papers for months!); it is a casual half-hour skim.</p><p>Unfortunately the committee’s request for my inclusion in the Expert Forum got lost in the mail, so I’ve been forced to publish my more subjective thoughts on Medium <a href="https://medium.com/@regit/ai-index-thoughts-d745c0159205">here</a>.</p><h4>Volume of Activity (how much)</h4><ul><li>Growth rate in publishing of papers in AI is 5x the growth rate in publishing of papers in all other fields since 1996, and 1.5x the growth rate in publishing of computer science papers.</li><li>Interest in deep learning has not necessarily revived interest in other types of AI, as evidenced by conference attendance; the AAAI (Association for Advancement of AI) conference, which is typically associated more with symbolic reasoning, has seen attendance drop from ~5000 in the 1980’s to ~1500 today, while NIPS has gone from ~500 attendees in 2000 to ~5000 today.</li><li>Annual VC investment in startups was at ~$3.5B last year, following a huge spike earlier this decade.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*8HlE9YUdJlbqEoUAUwA27Q.png" /></figure><ul><li>Sentiment analysis of media coverage of AI shows that positive classifications went way up in 2016.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*ZzxavIlql7hAR7R4jfjHAQ.png" /></figure><h4>Technical Performance (how good)</h4><ul><li>State-of-the-art AI performance has passed human-level performance in object detection (in 2015) and speech recognition (in 2016).</li><li>State-of-the-art AI performance still lags behind human-level performance in textual (AI 79% accuracy, human 83% accuracy) and visual question answering (AI 68% accuracy, human 83%).</li></ul><h4>Derivative Measures (how trends relate)</h4><ul><li>This is one of my favorite graphs in the report. It illustrates that researchers drove interest in AI in the early 2000s, which prompted higher higher enrollment in AI-related classes around 2010, and finally investor money hopped on the AI train earlier this decade. This fits nicely into a narrative about the progress of AI this century.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*T0IYDfr54y67qiE8rcl1DA.png" /></figure><h4>Towards Human-Level Performance? (how close to human-level performance)</h4><ul><li>The biggest issue with current implementations of neural networks is that they are very narrowly trained and thus performance is quite fragile. If the target task is moved even slightly from the expectation formulated during training, performance can fall off a cliff. Nevertheless, AI has been able to achieve several real-world milestones against human competition, with more barriers seemingly falling every month.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*ZDi4jBsYpHPTL3bx9oCK2A.png" /></figure><h4>What’s Missing?</h4><ul><li>We need more standardization for both benchmarks and research practices across the industry in order to be able to trust and compare published results.</li><li>Almost all of the data in this report comes out of the US, even though China is neck-and-neck in terms of progress in AI and countries like the UK and Canada are experiencing huge surges of interest in the field as well.</li><li>Echoing a sentiment in the tech industry at large, diversity and inclusion are ongoing issues in AI, and it’s a red flag that there isn’t any available data on this.</li><li>This report covers VC investment, but government and corporate investment into AI likely have even larger impacts. There’s no data on these types of investment.</li><li>Ethics in AI is an ongoing conversation that can’t be ignored: safety, predictability, fairness, privacy, etc.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1qlarXqP0QeXPqO07YYCGg.png" /></figure><h4>Expert Forum</h4><p><em>(I’m summarizing folks’ thoughts here. Stuff will inevitably get lost in translation, so plz don’t draw any conclusions from this without reading their entire bit in the forum)</em></p><ul><li>Although the authors were quite thorough with <em>What’s Missing</em>, the most common theme in the Expert Forum was emphasizing or piling on to this section. Particular areas of concern were ethics, safety, diversity, and inclusion, and US-centricity.</li><li>Kai-Fu Lee (Sinovation Ventures) notes that people in China use their phones to pay for goods 50x more than Americans and have 10x higher online food delivery volume despite having 3x the population, indicating a potential goldmine of data collection since the people are so much more engaged in technology. He also brings up the China State Council’s “Next Generation Artificial Intelligence Development Plan”, which is putting the full weight of the government behind an effort to make China the global leader in AI by 2030.</li><li>Andrew Ng (Coursera, Stanford) compares AI to electricity in terms of its impact across almost every industry in the world.</li><li>Daniela Rus (MIT) highlights the potential democratization of education through AI. She sees a world where any child anywhere in the world can receive an AI-designed curriculum online that adapts to their progress and learning style.</li><li>Sebastian Thrun (Stanford, Udacity) compares AI to the steam engine in its ability to automate repetitive work and free people to dedicate more time and energy to make advancements in society. This is both a blessing and a potential curse, as people whose jobs will be displaced by AI must adapt to survive.</li><li>Michael Woolridge (Oxford) calls AI a bubble, but he expects a gentle deflation over the next few years as steady progress replaces explosive progress, rather than an all-at-once implosion.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ts8EWOHguelKwsHDFQoIeQ.png" /></figure><h4>Conclusion</h4><p>This is an exciting beginning to a fantastic project. I can’t wait for AI Index 2018, and even more so AI Index 2038.</p><p>My detailed thoughts on the AI index can be found <a href="https://medium.com/@regit/ai-index-thoughts-d745c0159205">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae0e3a8083d8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paper-club/ai-index-index-ae0e3a8083d8">AI Index Index</a> was originally published in <a href="https://medium.com/paper-club">Paper Club</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI Index Thoughts]]></title>
            <link>https://medium.com/paper-club/ai-index-thoughts-d745c0159205?source=rss----754aaa9b86fd---4</link>
            <guid isPermaLink="false">https://medium.com/p/d745c0159205</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Tiger Shen]]></dc:creator>
            <pubDate>Thu, 14 Dec 2017 03:01:25 GMT</pubDate>
            <atom:updated>2017-12-13T21:21:57.278Z</atom:updated>
            <content:encoded><![CDATA[<p>Since Andrew Ng’s letter to me was typed and not handwritten, I’ve decided to publish my thoughts on the AI Index here instead of being included in the Expert Forum.</p><p>For my summary of key/favorite points see <a href="https://medium.com/@regit/ai-index-index-ae0e3a8083d8">here</a>, and to view the report itself go <a href="http://www.aiindex.org/">here</a>. I’ll reiterate that it only takes 15–30 minutes to skim through the bulk of the report, and I’d highly encourage you do so!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*2Nh2uihQy5nF9lnDcn0Ccg.png" /></figure><h4>Background</h4><p>In April 2017, a small group of software engineers that met each other taking computer science classes together decided to take the plunge into deep learning. That group eventually became Paper Club, and since then we’ve gone through parts 1 and 2 of <a href="http://www.fast.ai/">Fast AI</a>, entered various Kaggle competitions, and tried to read one AI-related paper a week.</p><p>But seven months is barely enough to scratch the surface! I’m still quite fresh in this domain. More than anything, I’m excited — to continue my own path through this material, and to witness how AI will change the world over the coming years. The content of the AI Index raised and reassured this feeling quite a bit.</p><p>With that out of the way, here’s a grab bag of my thoughts on AI index 2017.</p><h4>Academia-Industry</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*T0IYDfr54y67qiE8rcl1DA.png" /></figure><p>This piece of the report echoes what has been a recurring theme in Paper Club: theory vs. practice. How much time should we dedicate to reading papers, vs. entering Kaggle competitions? Doing linear algebra exercises vs. training models for a side project? Should we read old fundamental papers or new cutting-edge papers?</p><p>Since most of our members’ respective programming backgrounds are in bootcamps and/or self-teaching, we have experience with the bad habits that can form fumbling high-level libraries without having a clue what’s going on underneath the hood. However, we are also taking our own free time outside of work to learn this stuff, and would quickly lose interest if we were just going through worksheets of math problems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*wjoSL11-dCZhh8gtIImi6Q.png" /></figure><p>This graph demonstrates a natural progression of ideas and interest in AI this century; starting with researchers, trickling down to students at universities, and now making its way into startups and industry.</p><p>My interpretation of this data is that now is a good time to lean towards practical application of the hard-won ideas produced by universities and big companies over the past few years. The growth trajectory for business interest has caught up (and may soon surpass) the interest in research/education as these powerful concepts are aimed towards solving real-world problems.</p><h4>Encouraging Trends in Technical Performance</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*NpxwhmB3E9EWBGi_ScjqpQ.png" /></figure><p>Although humans are still better at more “difficult” tasks like document/visual question answering, they are not improving at nearly the rate of neural nets.</p><p>For example, in the graph above plotting document question answering accuracy, we can see that just in the last two years the state-of-the-art AI has improved it’s accuracy by almost a third, going from 60% to almost 80%. It’s not hard to imagine these sections of the report singing a different tune in the next iteration or two of the AI Index.</p><h4>Oh, the Irony</h4><p>I find it somewhat ironic that a big recurring theme is difficulty finding relevant, trustworthy data. That just so happens to be the biggest problem facing the domain that the report is reporting on!</p><h4>Accessibility</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*th_GdXXHokAVmfRGy2Fa3A.png" /></figure><p>With a bit of extrapolation, the AI index was able to produce some trends around university enrollment in AI-related classes (pictured above). While this is a good start, it represents a very narrow demographic of potential deep learning lifers. I would love to see more thoughts and data around the accessibility of the industry to newcomers.</p><p>This is especially notable to Paper Club. When we first surveyed the landscape, all we saw was a ton of math and required computing power. This was quite intimidating (even to the guy with a math major!). One of the reasons we started with Jeremy Howard’s fast.ai course (which is excellent, btw) is because of its promise to demystify deep learning. We couldn’t be happier with that choice, as it gave us the confidence and tools to keep going and get into more complex material.</p><p>Improving on and developing similar MOOCs or readily available books will widen reachable audience by a ton. Continued focus on the quality of open source tools will prop up the feeling that my single GPU and I can take on the world.</p><h4>Mainstream Media Coverage</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*ZzxavIlql7hAR7R4jfjHAQ.png" /></figure><p>Current media coverage of AI seems to be quite positive based on the data presented in the report. Given the built-in doomsday scenario with AI, how long will this last before naysayers get their chance? My experience has been that the media bounces back like a rubber band when its sentiment on a topic gets stretched too far in one direction. The general public can be wary of new technological developments, especially ones without clear explanations (which I would say currently describes neural networks). I hope new articles continue to trend positive, but would not be surprised if things took a turn for the worse.</p><h4>Diversity and Inclusion</h4><p>Diversity and inclusion in AI has a much greater impact than in almost any other industry because of the potential catastrophic consequences of machine bias in AI algorithms that are developed in a vacuum with a hivemind. This makes it even more worrying that we’re unable to surface reliable diversity and inclusion data in the industry — I can’t offer much right now, but I think it should be a priority and I sure hope this changes in the near future!</p><h4>Future Milestones</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*ZDi4jBsYpHPTL3bx9oCK2A.png" /></figure><p>The Milestones timeline was a great visualization of the progress in AI, as AI has been able to beat humans at exponentially harder tasks in sub-linear time over the past few years. I would also like some kind of insight into what the next barriers to fall will be, and how close we are to breaking them.</p><h4>General AI</h4><p>One area of interest that I would like to see included in future reports is progress towards general AI (i.e. an AI that can “think”, reason, and approach new tasks and problems like a human does).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*66zMmJuZ2HYtzmLUnUmVIQ.png" /></figure><p>Like it or not, achieving general AI is a breakthrough that would instantly change the word. Expert opinions differ vastly on timelines and viability for general AI, and that’s okay — I want to read about all sides of this discussion! If there’s no substantive progress towards general AI, I want to hear about that as well.</p><p>AI Index is part of the 100 Years Study on AI at Stanford, and as time goes on I think they’ll have to turn their ears more and more towards general AI.</p><h4>Conclusion</h4><p>I’m very happy that the AI Index is a thing. My conclusion here is the same as it was for my summary: this is an exciting beginning to a fantastic project. I can’t wait for AI Index 2018, and even more so AI Index 2038.</p><p>P.S. There’s a weird downwards dip in the graph of News Translation BLEU scores over time on page 29. If anyone know what’s up with that I’m curious.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*oR16BGSi1UacpGzYzgd6rw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d745c0159205" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paper-club/ai-index-thoughts-d745c0159205">AI Index Thoughts</a> was originally published in <a href="https://medium.com/paper-club">Paper Club</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Research to Practice]]></title>
            <link>https://medium.com/paper-club/from-research-to-practice-b2e2ecd292fb?source=rss----754aaa9b86fd---4</link>
            <guid isPermaLink="false">https://medium.com/p/b2e2ecd292fb</guid>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Tiger Shen]]></dc:creator>
            <pubDate>Sat, 11 Nov 2017 21:44:45 GMT</pubDate>
            <atom:updated>2017-11-11T21:44:45.259Z</atom:updated>
            <content:encoded><![CDATA[<h4>Notes on <em>Best Practices for Applying Deep Learning to Novel Applications</em></h4><p><strong>TL;DR:</strong></p><ul><li><strong>Get prepared</strong></li><li><strong>Prepare your data</strong></li><li><strong>Find an analogy between your application and the closest deep learning applications</strong></li><li><strong>Create a simple baseline model</strong></li><li><strong>Create visualization and debugging tools</strong></li><li><strong>Fine tune your model</strong></li><li><strong>End to end training, ensembles, and other complexities</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*cpuB9pgtIEDiusfJCYwDMw.png" /><figcaption>ColorNet, from left: grayscale, prediction, original image</figcaption></figure><p>Leslie Smith is a researcher at the US Naval Research Lab. The NRL isn’t top of mind when it comes to deep learning research, but I have really enjoyed reading Smith’s papers. I’ve found them to contain just as many impressive contributions as folks at Google/Facebook/Baidu.</p><p>This paper covers recommended steps for using deep learning to solve problems in new or adjacent domains. It does not introduce a novel architecture or propose a mind-bending new training technique, but I think its content is just as important for the growth of deep learning and is often overlooked by researchers.</p><p>Because the format of this paper is a bit unique, I’ll be covering it as a summary list of notes with some commentary interspersed rather than using our Paper Notes Template.</p><h4><strong>Phase 1: Get prepared</strong></h4><ul><li><strong>Do you need deep learning?</strong> Do state-of-the-art machine learning/statistics techniques perform well enough for your use case?</li><li><strong>What does success look like?</strong> This is best stated quantitatively, ideally with a metric or two you are optimizing for.</li><li>Are there any shortcuts you can take? Ways you can get by with less data? Data preprocessing, heuristics?</li></ul><blockquote>Important to distinguish between making the network’s job easier by giving it a cleaner dataset (good) vs. manual feature engineering (bad, this somewhat defeats the purpose of using a neural network)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*UtGFbmJ6h75pfkyXZbEiEg.png" /><figcaption>Neural style transfer</figcaption></figure><h4><strong>Phase 2: Prepare your data</strong></h4><ul><li>Where’s your data coming from? How much do you have? What level of confidence do you have it?</li></ul><blockquote>I wish transfer learning were given more of an emphasis here, rather than just being mentioned in passing. From my experience in the fast.ai course, transfer learning is often the option that best balances time/effort and performance.</blockquote><ul><li>Does your data cover the entire problem space?</li></ul><blockquote>If you’re trying to predict digits 0–9, make sure you have at least one of each class! Might seem obvious but when you get into large classifiers it can be overlooked.</blockquote><ul><li><strong>Is the class distribution of your data representative of the problem space?</strong></li></ul><blockquote>Sometimes this isn’t ideal, e.g. if you are trying to predict the presence of a cancer that appears in 0.05% of tests in the real world, you would want a higher percentage of your training set to be positive results. Just be aware of it and adjust accordingly.</blockquote><ul><li><strong>Normalize and zero mean</strong> your data. Pretty much no reason not to</li><li>Can you use techniques to lower your data’s dimensionality using PCA or SVD without losing too much information?</li></ul><blockquote>For novel deep learning applications, this is likely the most important phase. I think the importance of data is <em>still </em>not emphasized enough as compared to more exciting areas of research like neural net architectures. Hopefully the <a href="https://techcrunch.com/2017/08/15/andrew-ng-is-raising-a-150m-ai-fund/">money talks</a> and that changes.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mNdWU4z2Gw9mt1NCz5oelQ.png" /><figcaption>Word2Vec embeddings mapped into multi dimensional space</figcaption></figure><h4><strong>Phase 3: Find an analogy between your application and the closest deep learning applications</strong></h4><ul><li>Most low-hanging applications of deep learning have already been tackled by researchers, and chances are that yours can take inspiration from something that already exists. The author suggests this breakdown of categories:</li><li>Image classification: CNNs</li><li>Sequential/temporal data: RNNs (LSTM/GRU)</li><li>Decisionmaking: deep reinforcement learning</li><li>Use code or takeaways from this step to inform your approach to the next one</li></ul><blockquote>Again, the author is getting almost all the way to <strong>transfer learning</strong> here; I wonder why they don’t take one more step and suggest not only finding code, but finding weights and biases that you can start your own model with.</blockquote><h4><strong>Phase 4: Create a simple baseline model</strong></h4><ul><li><strong>Make a network that is as small as possible</strong>, with a minimum number of layers and parameters, using a common loss function and safe hyperparameters.</li></ul><blockquote>Throughout his <a href="http://course.fast.ai/">fast.ai</a> course (highly recommend btw, Paper Club has gone through both parts together), Jeremy Howard approached problems by building a network with just an input layer, one hidden layer, and an output layer. This might sound useless at first, but time after time it was enough to start to see convergence. I have personally found this approach quite profitable.</blockquote><ul><li>Train on a subset of your training data to short the feedback cycle.</li></ul><blockquote>As long as there is enough data for the model to converge, it’s enough for this step.</blockquote><ul><li>Unit test your network</li></ul><blockquote>I have literally never seen a unit tested neural network, and this makes me wonder a) why not and b) what tools even exist to do so.</blockquote><ul><li>Take advantage of a framework like TensorFlow or PyTorch</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*OPNjgGFHVzYd55hycpvlVg.png" /><figcaption>Image super-resolution</figcaption></figure><h4><strong>Phase 5: Create visualization and debugging tools</strong></h4><ul><li>“Code once, measure twice”.</li></ul><blockquote>From phases 1 and 2, you should have a very solid idea of the types of results you expect to be getting. Now it’s time to be meticulous about comparing these to your actuals. Check that your architecture, weights, biases, etc. conform to your expectations. I personally find myself printing out the numpy shapes of almost every important tensor in my network at some point or another.</blockquote><ul><li><strong>High bias</strong> vs. <strong>high variance</strong>: high bias means that your network is converging to the wrong minima or a local minima, and can be addressed with a larger network. High variance means that your network is not converging at all, and suggests that your training data is inadequate.</li><li><strong>Error analysis</strong> vs <strong>ablative analysis</strong>: error analysis is your classic loss, representing the difference between your network’s performance and a perfect performance. Ablative analysis is the process of setting up a baseline, changing things one at a time in your network, and noting how the altered network compares to the baseline. Both are useful.</li><li>TensorBoard, which is bundled with TensorFlow, is a recommended tool to use</li></ul><h4><strong>Phase 6: Fine tune your model</strong></h4><ul><li><strong>Change everything!</strong> You should tinker with every aspect of your network and record how it affects performance: the architecture design, depth, width, pathways, weight initialization, learning rate, etc.</li></ul><blockquote>You will likely find yourself faced with the problem of overfitting at some point during this process, when your training accuracy keeps improving but your validation accuracy plateaus or goes down. This is a classic machine learning problem, and the first thing to do when you see it is pat yourself on the back because you have a network that is learning! Then, just follow the <a href="http://wiki.fast.ai/index.php/Lesson_3_Notes#Overfitting">established playbook</a> for mitigating it:</blockquote><blockquote>- Add more data</blockquote><blockquote>- Use data augmentation</blockquote><blockquote>- Use architectures that generalize well</blockquote><blockquote>- Add regularization</blockquote><blockquote>- Reduce architecture complexity.</blockquote><ul><li>The <strong>loss function</strong> is the most important component of your network, so make sure you think deeply about what type of loss function is appropriate and test several that might fit your criteria.</li><li>This phase is completely open-ended, and without some measure of self-control it might end up being just that. Be sure to constantly refer back to your stated goals from phase 1, and force yourself to stop when you reach them, quieting the voice in your head nagging you about that new loss function that you haven’t tried yet.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*BFG_B7UpS3AvJxE6lH0lug.gif" /><figcaption>Neural Doodle</figcaption></figure><h4><strong>Phase 7: End to end training, ensembles, and other complexities</strong></h4><ul><li>There’s still more! The author notes that it’s totally unnecessary to use these if you are satisfied with your network performance, but suggests two that might be most rewarding: end to end training and ensembling. End to end training means trying to consolidate a system with multiple parts into just one neural network that takes the original input and produces the desired final output, even if they are of different formats (e.g. speech to text). Ensembling is the process of training multiple models with different random weight initializations and averaging or weighting their results in order to mitigate any biases or strangeness about the individual models.</li></ul><p>And that’s that! Just follow these 7 simple, straightforward, easy, clearly-defined, no-confusion-at-all, steps and you’ll be on top of the world 😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2e2ecd292fb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paper-club/from-research-to-practice-b2e2ecd292fb">From Research to Practice</a> was originally published in <a href="https://medium.com/paper-club">Paper Club</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>