<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hari Aakash on Medium]]></title>
        <description><![CDATA[Stories by Hari Aakash on Medium]]></description>
        <link>https://medium.com/@hariaakash646?source=rss-71a18bc871e8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*8uGygBIAiEKh1V7E.jpg</url>
            <title>Stories by Hari Aakash on Medium</title>
            <link>https://medium.com/@hariaakash646?source=rss-71a18bc871e8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 02:31:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hariaakash646/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Artificial Intelligence is basically Harry Potter?]]></title>
            <link>https://medium.com/geekculture/artificial-intelligence-is-basically-harry-potter-3251e5e3b64b?source=rss-71a18bc871e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/3251e5e3b64b</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[harry-potter]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[magic]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Hari Aakash]]></dc:creator>
            <pubDate>Sun, 07 Aug 2022 17:10:52 GMT</pubDate>
            <atom:updated>2022-10-13T06:24:25.343Z</atom:updated>
            <content:encoded><![CDATA[<p>When I was thinking of interesting analogies for Deep Learning, something cool struck me. The way Deep Learning models learn is miraculous, mysterious, or should I say <strong>magical</strong>. Well, is there any cool piece of fiction that I like that has magic in it… oh yes, the <strong>Harry Potter </strong>series. So let’s dive right into and find a wizarding match for the magic of Deep Learning.</p><h3>The Model, is Harry?</h3><p>The model is the protagonist of our deep learning story, so it is only right for it to be our Harry Potter. Everything(or everyone) else are puppets of the programmer(or *spoiler*) functioning with the aim to improve our protagonist’s performance in the<a href="#be94"> <em>final challen</em>ge</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*AB4yvty3KM1XSmbz9_T3Ww.jpeg" /></figure><p>The model inputs training data, learns from it, and uses this to make predictions from real-world data. Similarly, Harry gets inputs from Hogwarts classes and professors, and uses this to hone his skills for the final “<a href="#be94">real world application</a>”.</p><h3>The loss function is definitely Snape</h3><p>Well, this is one of the first ideas that struck me when I started to write this article. The loss function is our protagonist’s Snape. Both might seem too harsh in criticizing<strong> </strong>our hero’s performance, at times even feeling like an unavoidable obstacle. But they <strong><em>always </em></strong>function with the protagonist’s well-being in mind, and it is undeniable they play one of the most vital roles contributing to our hero’s success.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*AO2y6n6XXzmIcX_J7-o9Tg.jpeg" /></figure><p>The loss function compares the model’s predictions with the real values, and <em>‘criticizes’</em> the model by computing its error. But this is one of the most important parts of optimizing any deep learning model, without this our model doesn’t stand a chance in the final task. Similarly, Snape might seem like a nuisance to Harry, but his contribution to the eventual victory is undeniable.</p><h3>The Training Data is the castle</h3><p>The training data is of course Hogwarts itself. All the learning of our protagonist occurs here. This includes his classes, teachers, books, and of course friends.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*90fesRqTLeNCcPsktjwZww.jpeg" /></figure><p>The model learns from the training data and optimizes its performance to work well in the real world. Similarly, Harry learns almost everything from his time at Hogwarts, which makes sure he stands a chance in the <a href="#be94">final battle</a>.</p><h3>The optimizer</h3><p>An obvious optimizer of Harry Potter is his Hogwarts professors. They help our protagonist learn well from the input data and steer him on the right path. On the other hand, we have another optimizer, which definitely is Hermione Granger. She always nudges Harry in the right direction, sometimes even feeling a bit too bossy to our protagonist, but eventually makes sure our hero is optimized.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SVDrbrKf6wG_YRJS_ts9Qg.jpeg" /></figure><p>The optimizer updates the model’s parameters and tunes it to work better with the training data. Without a good optimizer, our model is nothing but a random bunch of numbers. Similarly, the Hogwarts professors and Hermione guide Harry and make sure he is well trained for the final challenge.</p><h3>Test Data, are basically O.W.Ls</h3><p>Ordinary Wizarding Level examinations, more commonly known as O.W.Ls test a wizard&#39;s skills and give a measure of how well they would fare in the real world. This might not be anything close to what our protagonist might face in the final threat, but this is nevertheless a way to evaluate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*9OMa9IfULDrC_4qclx8aYw.jpeg" /></figure><p>The test data is supposed to give the programmer an idea of how well the model might function on the real data. The test data could be nothing like what the model might encounter in the real world, but it is one of the few ways to test our model out of its comfort zone(the training data).</p><h3>The Real World</h3><p>Well, this is what everything so far has been building up to. The inputs from the training data, the criticisms from the loss function, the nudges from the optimizer, and the evaluation of the test data have all built up to this. Harry’s exit from the safety of Hogwarts into the real world to hunt Horcruxes and of course, the battle against Voldemort is our protagonist’s final challenge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*jmVYMOgh-CbhkJiWWXtdlw.gif" /><figcaption>Expelliarmus</figcaption></figure><p>This is where our model’s real challenge lies. It is not like the training data where the model can make mistakes and learn from them. It is not the test data where the programmer might correct our model’s mistakes. Here mistakes are not taken lightly. Maximizing the chances of our <em>model’s </em>success<em> </em>is what the <a href="#0672"><em>programmer</em></a><em> </em>works towards.</p><h3>The Programmer is …</h3><p>If everything discussed so far are puppets in a stage called AI then the programmer is the puppeteer. Similarly, Dumbledore is our programmer in Harry Potter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kiz3H88LP5BXvVsO8g6jtg.jpeg" /></figure><p>Dumbledore is the one who knows everything, has control over everything, and manipulates everything according to his plans. If someone has free will in the Wizarding World it is him. The programmer is definitely our Dumbledore. Everything discussed so far are pawns of the programmer. The success or failure of our protagonist solely depends on the prowess of the programmer. Everything that happens here is part of the Programmer’s(or Dumbledore’s) Big Plan.</p><h3>The End.</h3><p>So that was a fun little way to look at Artificial Intelligence. It definitely took a dark turn in the last part. This was a very fun article to write and I hope you guys enjoyed reading it. I’ll have a few bonus ones coming up with some of our most beloved(or hated) Harry Potter characters. Well, thank you for reading the article, and hoping to interact with you in the comments.</p><h3>Wrongly labeled data is obviously Umbridge</h3><p>Is there something Data Scientists hate more than wrongly labeled data? The answer is probably no. Is there someone who Harry Potter fans hate more than Umbridge? The answer is definitely a NO.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*UCvhY2GRrJCd_jXJu5OQjA.jpeg" /></figure><p>There is no bigger problem in a dataset than wrong labels and there was no bigger problem in Hogwarts than Umbridge.</p><h3>Software Design</h3><p>If an AI model is to be of any use in the real world, it needs great Software Design to accompany it. Similarly, for Harry to have any success in the real world Ronald Weasley needs to accompany him.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*ZM7fHKj2tOYefRQ9gOmBkg.jpeg" /></figure><p>An AI model without good software is just a brain without a body. Similarly, Ron in Harry Potter’s life is simply irreplaceable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3251e5e3b64b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/artificial-intelligence-is-basically-harry-potter-3251e5e3b64b">Artificial Intelligence is basically Harry Potter?</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Witchcraft of Deep Learning — Activation Functions]]></title>
            <link>https://medium.com/geekculture/witchcraft-of-deep-learning-activation-functions-4f6ed323ad78?source=rss-71a18bc871e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f6ed323ad78</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[activation-functions]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[artificial-neural-network]]></category>
            <dc:creator><![CDATA[Hari Aakash]]></dc:creator>
            <pubDate>Tue, 27 Jul 2021 05:50:52 GMT</pubDate>
            <atom:updated>2021-08-08T08:12:42.948Z</atom:updated>
            <content:encoded><![CDATA[<h3>Witchcraft of Deep Learning — Activation Functions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*TulMMQUeOrGhPKVL2arfFg.png" /></figure><p>One of the most important part of any DL model is the activation of each of its layer. An <a href="https://en.wikipedia.org/wiki/Artificial_neural_network">ANN</a> with 10 hidden layers without any activation function is essentially the same as an ANN with one hidden layer.</p><h3>Why even bother to add activations?</h3><p>You probably will be wondering why an activation function would have such a huge impact in a complex neural which seems to have parts with far more importance. Lets explore it,</p><p>We know that, <em>z = wx + b and a = activation(z)</em>. When the activation is linear <em>a = z. </em>So,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*SoVzqdxVru7_rinCpF7bZw.png" /></figure><p>This means that the impact of each layer disappears and the weights become the product of the weights of the previous layers. When a non-linear activation function is used this wouldn’t happen.</p><p>Lets try this out. We are using the <a href="https://www.tensorflow.org/datasets/catalog/mnist"><em>mnist</em></a> dataset in <strong>tensorflow</strong>. We have initialized the weights for all cases using <a href="https://www.tensorflow.org/api_docs/python/tf/keras/initializers/GlorotUniform"><em>Glorot Uniform</em></a> initializer with random seed 32. When using a linear activation,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*jEhxdYkzJ1VMIb67Y4Bz6g.png" /><figcaption>linear activation losses and accuracy</figcaption></figure><p>When using a non-linear activation called <strong>Relu,</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*GCcSXAJs4zTnE_8Z9iaDTg.png" /><figcaption>Relu activation losses and accuracy</figcaption></figure><p>We can clearly see a massive difference in the losses of both cases. The accuracy of the Relu activation is 99.24% whereas the accuracy of the linear activation model is only 91.44%. This accuracy is similar to what we might get with a model with one layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/963/1*x8cgcsITC-NNor7MY5geVw.png" /><figcaption>One hidden layer, linear activation</figcaption></figure><p>This clearly shows the importance of activations in any DL model.</p><h3>Comparison of Different Activation Functions</h3><p>There are various activation functions which are used in the field of deep learning currently. We’ll look at the most important and useful activation functions.</p><h4>Sigmoid</h4><p>The sigmoid activation function is mainly used in the final layer of binary classification problems. It returns an output of values between 0 and 1 which makes it very suitable for classification problems. It can be defined as,</p><p><em>a = (1/1 + e</em>⁻ᶻ<em>)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HXCBO-Wx5XhuY_OwMl0Phw.png" /><figcaption>graph of sigmoid activation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*SdQ6J0TXmkPUjrWpbRmtww.png" /><figcaption>sigmoid loss</figcaption></figure><p>Using sigmoid activation in the hidden layers seems to have a very good loss and accuracy. But it is not a good idea to use sigmoid in the hidden layers of huge models due to the vanishing gradient problem. The maximum possible gradient of sigmoid activation is 0.25 and it moves towards 0 in either of the ends. Because of this the gradient becomes very small when moving through each of the layers and this slows down training massively.</p><h4>Tanh</h4><p>Tanh returns values in the range of 1 and -1. It is mainly used in RNNs and LSTMs. It can be defined as,</p><p><em>tanh(z) = (eᶻ-e⁻ᶻ)/(eᶻ+e⁻ᶻ)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*NK0AjxnpDfULnQIxkuq_VQ.png" /><figcaption>graph of tanh activation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*xebVB-AHAz9nxRn_E_StzA.png" /><figcaption>tanh loss and accuracy</figcaption></figure><p>This model has a reasonable loss and accuracy. But just like sigmoid activation even this faces the issue of vanishing gradients.</p><h4>ReLU</h4><p>The ReLU or the Rectified linear unit activation function is the most popular activation function for the hidden layers of most deep learning models. This outputs 0 if the input is negative and the value of the output if it is positive. It can be defined as,</p><p><em>a = max(0, z)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QkZ5OYHJvCnYPigMJ2SIyg.png" /><figcaption>graph of ReLU activation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*GCcSXAJs4zTnE_8Z9iaDTg.png" /><figcaption>ReLU activation loss and accuracy</figcaption></figure><p>This model has the best loss and accuracy so far. It does not face the vanishing gradient issue like the other models and is the most popular activation function for hidden layers.</p><p>There is a variant of ReLU called <strong>Leaky ReLU</strong>.<strong> </strong>It is defined as,</p><p><em>max(z, alpha * z)</em></p><p>Here <em>alpha</em> is a hyperparameter(usually 0.1). This activation function is also popularly used for hidden layers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*T5k5Pgrgsti9F9G2MvPynQ.png" /><figcaption>Graph of leaky ReLU activation</figcaption></figure><h4>Softmax</h4><p>Since mnist is a multiclass classification problem we use softmax activation to classify the images. Softmax is almost never used for hidden layers but is very important in multiclass classification. It can defined as,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*t2FbP10uDFZrufDCYELWFA.jpeg" /><figcaption>softmax formula</figcaption></figure><p>The sum of all the outputs is equal to one. The maximum among the probabilities is chosen as the predicted label.</p><h3>Thank You!</h3><p>Thanks a lot for reading this article.</p><h3>The Code</h3><p>This is the code that was used:</p><pre>import tensorflow as tf</pre><pre>mnist = tf.keras.datasets.mnist</pre><pre>(x_train, y_train), (x_test, y_test) = mnist.load_data()</pre><pre>x_train, x_test = x_train.reshape(60000, 28, 28, 1) / 255. , x_test.reshape(10000, 28, 28, 1) / 255.</pre><pre>activation = ‘relu’ # Change for experimentation</pre><pre>initializer = tf.keras.initializers.GlorotUniform(seed=32)</pre><pre>model = tf.keras.models.Sequential([</pre><pre>tf.keras.layers.Flatten(input_shape=(28, 28)),</pre><pre>tf.keras.layers.Dense(256, activation=activation, kernel_initializer=initializer),</pre><pre>tf.keras.layers.Dense(512, activation=activation, kernel_initializer=initializer),</pre><pre>tf.keras.layers.Dense(512, activation=activation, kernel_initializer=initializer),</pre><pre>tf.keras.layers.Dense(256, activation=activation, kernel_initializer=initializer),</pre><pre>tf.keras.layers.Dense(10, activation=’softmax’)])</pre><pre>model.compile(‘adam’, ‘sparse_categorical_crossentropy’, metrics=[‘accuracy’])</pre><pre>history = model.fit(x_train, y_train, epochs=10, callbacks=[callback], validation_data=(x_test, y_test))</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f6ed323ad78" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/witchcraft-of-deep-learning-activation-functions-4f6ed323ad78">Witchcraft of Deep Learning — Activation Functions</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>