<?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 Shikha Aggarwal on Medium]]></title>
        <description><![CDATA[Stories by Shikha Aggarwal on Medium]]></description>
        <link>https://medium.com/@shikha-aggarwal?source=rss-899cfd4c7858------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*WrAQqydRCjHl0o8iAfkiHw.jpeg</url>
            <title>Stories by Shikha Aggarwal on Medium</title>
            <link>https://medium.com/@shikha-aggarwal?source=rss-899cfd4c7858------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:34:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shikha-aggarwal/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[Boondi]]></title>
            <link>https://shikha-aggarwal.medium.com/boondi-3f159b3af1ce?source=rss-899cfd4c7858------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f159b3af1ce</guid>
            <category><![CDATA[simple-life]]></category>
            <category><![CDATA[india]]></category>
            <category><![CDATA[childhood-memories]]></category>
            <category><![CDATA[innocence]]></category>
            <category><![CDATA[food]]></category>
            <dc:creator><![CDATA[Shikha Aggarwal]]></dc:creator>
            <pubDate>Thu, 01 Jul 2021 21:14:20 GMT</pubDate>
            <atom:updated>2021-07-01T22:47:33.485Z</atom:updated>
            <content:encoded><![CDATA[<p>When Chandni woke up, it was finally Tuesday. Tuesday was the day of worshipping Hanuman — the God who never married and spent his life serving other people. She woke up promptly and got ready for school. She was looking forward to the evening and these rote tasks were non-negotiable. When she hopped on to the school bus, the driver addressed her “laddoo is here.” Her giggle was louder than usual.</p><p>In afternoon when she was back home, she went to her mom in the kitchen. “How was your day?” she asked her mom who smiled and said, “What are you so happy about? Got any test results?” “Uff. No tests.” She hopped out of kitchen. Everything was peaceful at home, which meant the trip to the Hanuman temple was on. She just had to assure that her younger brother doesn’t piss off her parents until then. The whole family sat down to have lunch.</p><p>In evening, it was finally that time. Her dad kick start his Bajaj Chetak scooter and she hopped on behind him. Her little brother slid under dad’s arm and took his standing position in front of dad. And at last, mom took her seat behind Chandni — both her legs dangling in one direction. They drove to the market where scooter drivers crawled neck-to-neck among rickshaws, autos, honking cars, a few cows, and a lot of pedestrians. People in the front wanted to go to the back, and people in back itched to get to the front.</p><p>As they neared the destination, it got even more busier and noisier. Chandni craned her neck over dad’s shoulder and tried to look ahead to check out the carts selling toys and food and sweets near the temple. Her dad told her mom, “are you seeing this crowd? what good would a car be here?” Her mom had often told dad that they needed to buy a car now that Chandni and her brother were growing up. After they had passed another rickshaw, her brother said irritably, “This is taking forever! I won’t be able to make it in time for cricket! You said we will be back by 6.” Dad said, “Hey! Don’t talk like that. This is important too!”</p><p>They parked the scooter and got off in the reverse order of seating. Her mom covered her head with dupatta. Chandni held her dad’s hand — her brother on his other side — and waited breathlessly to follow him to one of the carts. The cart with a huge bright yellow heap of boondi. The golden magic balls that would pop and melt in mouth and make all this worth it. The yellow translucent pearls she would wait the whole weak for!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4skTwdy6zR3mQGmuvj4e6g.jpeg" /><figcaption>Boondi</figcaption></figure><p>Her dad would always buy the smallest Rs. 2/- bag. Timidly, she said, “Papa, can we get the Rs. 5/- one?” He replied, “we always end up wasting these.” He looked at her mom and asked, “No?” She was busy looking at something across the street and dad turned towards the cart vendor and said, “One bag of 2 rupees please.”</p><p>The vendor carelessly wedged an aluminum spatula into the boondi heap and tilted it into a brown paper bag. The balls rolled into it. Chandni could imagine how good the moist and plump juicy balls would be! The vendor then weighed the bag on his scale and took some of the boondi out. He folded the top of the bag onto itself and handed it over to dad. The bag was already stained with some of the sugar syrup from the fresh boondi.</p><p>With the bag held by his side, she walked down the wet red carpet — avoiding the wet patches. They stored their chappals near the entrance and washed hands. When they neared the marble deities covered with red tilak and chunnis, Dad asked Chandni and her brother to say their prayers and handed over the bag to the priest. Her hands were joined, but her half-opened eyes followed the bag. The priest tilted it into a utensil set at the foot of the deity of Hanuman which was already full of boondi and other kinds of sweets, and handed back about half of the bag back. Sometimes it was even less. Her dad accepted it with both his hands. He was grateful.</p><p>She could sense that the moment was very close. On their walk back on the red carpet, kids in tattered clothes would surround them and pull at her dad’s shirt asking him to share the prasad (the boondi after being offered to God was called prasad). He took out some and gave it to everyone who asked and those who didn’t. Usually there would be very few kids because they would be busy somewhere else; but this time there were many more.</p><p>She kept behind him and watched him share the prasad. They collected back their chappals in midst of this sharing, and started walking towards their scooter. It always seemed that they had run out of prasad but whenever someone asked for some, dad always managed to tilt the bag and dish out some more and share. Finally, when they reached the scooter, she raised both her hands to him and her brother did too. Mom stood by. Her dad took out the last bits and handed 2 tiny balls each to her and her brother. She looked at hers and what was in brother’s hand. “So less?” she asked frustrated. Her brother ate it and took his place on scooter. “Let’s go! Match time!!” he yelled.</p><p>“But I got only two boondis!” Chandni said.</p><p>“All is gone. Prasad is prasad — the quantity doesn’t matter,” her father smiled at her. “Here, take some more –” and he handed two more balls and then gave one to mom and he just brushed his hand over his hand as a blessing from prasad.</p><p>Seeing his daughter frowning, he said, “should we buy more?”</p><p>She dropped her face and shook her head. Then she enclosed the four balls in between her hands and closed her eyes and said a prayer. Opening her eyes, she smiled, and popped her four balls into her mouth. She closed her eyes again and felt the balls pop and melt into sugar in her mouth. It was the best boondi she had head. Perfect. Fresh. Then she licked her palm where the boondi had been. She hopped on to the scooter and rode back home. In just another week, she would get more.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f159b3af1ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dissecting GPT]]></title>
            <link>https://shikha-aggarwal.medium.com/dissecting-gpt-1aa6429d1ec5?source=rss-899cfd4c7858------2</link>
            <guid isPermaLink="false">https://medium.com/p/1aa6429d1ec5</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Shikha Aggarwal]]></dc:creator>
            <pubDate>Tue, 15 Dec 2020 07:40:15 GMT</pubDate>
            <atom:updated>2020-12-15T07:40:33.157Z</atom:updated>
            <content:encoded><![CDATA[<h3>Dissecting GPT-2</h3><p><em>[Sorry for the delay. I traveled to India for my brother’s wedding but it had to be postponed because my parents got covid-19. The last 12 days we spent keeping them in isolation, and they are fine now!]</em></p><p>Side thought: The whole system of education is so confusing because it is hard to determine when you should transition from just consuming to start taking the lead. I will go with my gut feeling that says “as soon as you learn anything.”</p><p>Now back to the topic. GPT is insanely famous in the ML world. I am not the best judge of the novelty of the techniques in it, but I initially approached it as though every bit in it was new but that is not completely true.</p><p>These are the building blocks that constitute it:</p><p>Encoder-Decoder structure. Remember that I covered Transformer last time? Because of the popularity of that paper, I was led to believe that encoder-decoder was their breakthrough. But that architecture has been around for sometime (and I knew it but had forgotten!! — old problem). LSTMs do the same thing (that is the only other model I have read in small detail). Anyway, the innovation of models is mostly in the circuits within the individual blocks — encoder and decoder in this case.</p><p>Attention. Again, it has been around for some time.</p><p>Attention supposedly highlights the context of the sentence that is important for the current word being processed. So, if we have a sentence “Manu thinks he is a superstar,” here ‘he’ refers to Manu and attention block’s ideal output should give most weight to Manu when input is ‘he’ (input comes in the form of word/token embedding + positional encoding which are respectively absolute information about the word and relative information of the word to the text around it. Positional encoding can take into account multiple sentences depending on how big we have allowed our context size to be during training. GPT sets it to be 768 in the smallest model to 1600 in the largest. Average sentence length in <a href="https://www.quora.com/How-long-is-the-average-sentence/answer/Simon-Wang-15">English is 20 words.</a>)</p><p><em>How is this done?</em></p><p>We train magic-like vectors Q, K, V in an attention block.</p><p>Now comes the part where I have interpreted these matrices in terms that makes it easier for me to think and visualize what is going on.</p><p>Remember word embeddings? Think of them as vectors in a large dimensional space where representing each word. The main feature is that the position of the words in the space tells us about the relationship with other words. We can think of dimensions of the space as different features of a word: adjective, male/female, verb, article, … and so on. The famed example of VKing — VMan + VWoman = VQueen tells us that a word can be represented as a linear combination of vectors of the words “nearby.”</p><p>Now, when we want to represent a word such that it also carries hints of what has preceded it, we want some sort of linear combination of the words that are related to it.</p><p>Example, if we have a sentence, “<em>Memories are like mulligatawny soup in a cheap restaurant. It is best not to stir them.</em>”</p><p>Here, “stir” is influenced more by “soup” than “restaurant” or “cheap.” To capture this relation, we train two sets of vectors for each word (Q and K): so that we can take dot product and get some sort of relevancy score between two words.</p><p>Then once we have a relevancy score, we need yet another third vector (V), which will actually be used in the linear combination equation to get the vector for the current word. This will be the output: a “word-vector” of the current word which has paid “attention” to the past words.</p><p>For more details, and a different spin on this, please refer to<a href="http://jalammar.github.io/illustrated-gpt2/"> Jay Alammar’s post</a> as always.</p><p>Putting it all together for GPT-2:</p><p>Once we have this attention-vector, we will compare it with all the words in the vocabulary to see which one is the closest match. How do we do it? We train yet another matrix of the size of (vocab size) X (vector size of the output vector above) which is supposed to contain the vector expected. We take our output vector and take a dot product with each one of the vectors in this huge matrix: each giving a score for each word in vocabulary. The max one is the closest word.</p><p>Note that this setup also gives us a hint to how it is trained: It consists of only decoders stacked atop each other. The last matrix is one which gives us the vector for the next word. While training, we already know the next word. So, it is easy to see back propagation from here since it is all matrix multiplication.</p><p>PS: I am sort of stuck because I am visiting home and forgot to bring my iPad to treat all of us with amazing visuals to go with the blogpost. But I will resolve this soon and update the post soon with my art work!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1aa6429d1ec5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GPT to write Wodehouse*-like]]></title>
            <link>https://shikha-aggarwal.medium.com/gpt-to-write-wodehouse-like-ac9a72b6eb07?source=rss-899cfd4c7858------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac9a72b6eb07</guid>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[books]]></category>
            <category><![CDATA[gpt]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Shikha Aggarwal]]></dc:creator>
            <pubDate>Fri, 20 Nov 2020 23:46:08 GMT</pubDate>
            <atom:updated>2020-11-20T23:46:08.457Z</atom:updated>
            <content:encoded><![CDATA[<p>*<a href="https://en.wikipedia.org/wiki/P._G._Wodehouse">P. G. Wodehouse</a></p><p>For the longest time, I wasn’t able to start with NLP because I did not know “all” the basics and it seemed like too much tedious work. I lost interest during online lectures because they are usually one-way, are not tailor made to a student’s needs but very generic and sometimes too basic. It simply takes quite a bit of effort to keep going. But writing code, seeing results, reading to improve them are rewarding. So that’s what I am doing now.</p><p>Things I started and did not complete a hundred percent:</p><ul><li>An absolute necessity: <strong>CS224n Natural Language Processing with Deep Learning taught by Chris Manning</strong> at Stanford. This is my favorite till now and I do hope I complete it.</li><li>Textbook: Speech and Language Processing by Jurafsky and Martin. (First 3 chapters): Great resource to understand the field of NLP in detail: the problem, evaluation of solution. Will continue to read.</li><li>NLP specialization on Coursera (finished 4 out of 5 courses): While the lectures are good, I thought assignments are not very engaging. There were some where I was just supposed to run all the Jupyter notebook cells. While that was some excellent code written there, going through all of it will not be as good a learning experience as implementing something on my own.</li><li>Learning series by Deepmind on YouTube. Great lectures but no practice.</li></ul><p>What I learned:</p><ul><li>Fundamentals of the ML process: preprocessing, model evaluation, and reiteration — These are where one needs to show patience, out-of-box thinking, and immense technical skills.</li><li>There are so many libraries available to train the models that it is not techie anymore to do it. Training requires expertise parallel to creating a web page on Wordpress or something.</li></ul><p>So much talking. Here is me dipping my little toe finger’s nail in the water: <a href="https://github.com/shikha-aggarwal/wodehouse-generator/blob/main/gpt2_huggingface_GPU.ipynb">https://github.com/shikha-aggarwal/wodehouse-generator/blob/main/gpt2_huggingface_GPU.ipynb</a></p><p>I took the GPT and “fine tuned” it on stories by PG Wodehouse (scrapped from <a href="http://gutenberg.org/">Project Gutenberg</a> website). [Why Wodehouse? Because … blah. Just go and read <a href="http://www.gutenberg.org/files/3829/3829-h/3829-h.htm"><em>Love Among the Chickens</em></a> first and then come back.]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wHB8nfNP6nDwZ_YTiB3z5w.jpeg" /><figcaption>GPT at work to write like P.G. Wodehouse</figcaption></figure><p>Here is the auto generated content:</p><blockquote>Prompt: “It was in Oxford Street at the hour when women come up from the suburbs to shop; and he was standing among the dogs and commissionaires outside Selfridge’s.”</blockquote><blockquote><strong>Generated text 1:</strong> He was feeling that strange exhilaration, the thrill which comes to those who have done well at school, the triumphal glow which leads down the aisle at the Savoy and reaches even to the children’s section of department stores.</blockquote><blockquote>All he had to do was to hang about and wait, and soon the other fellow would get busy and do it at him, and it would be his triumph. As for me, I would merely sit there. He had shown me hitherto nothing but a bleak future. In fact, at the present moment I rather fancy that my existence in the neighbourhood would be a trifle dull.</blockquote><blockquote><strong>Generated text 2: </strong>“Gimme dat, Liz!” He waved a hand towards the stricken lady. “A couple,” he explained. He did not go into great detail, but in his opinion the matter was one that called for explanation. Sally was in an exalted mood. She might be able to fight the craving, but it seemed that she must come to some conclusion to it. “What do you mean by it?” “Well, what do you want? Why should I keep my love for you hidden?” He produced another cigar from his pocket and relit it.</blockquote><p>The text reads incredibly Wodehousian to me! Even though the story goes a bit awry here and a lot more pretty soon, the language skills (grammar, word choice, dialogue style, punctuations) look pretty solid.</p><p><strong>What is this GPT that is working kind of well?</strong></p><p>I tried reading OpenAI’s <a href="https://openai.com/blog/language-unsupervised/">article and paper</a>. The second line says “Our approach is a combination of two existing ideas: transformers and unsupervised pre-training.” Eh — transformers? Taking a step back, I read this: <a href="http://jalammar.github.io/illustrated-transformer/">The Illustrated Transformer</a>.</p><p>I learned that a Transformer is a model consisting of an encoder and a decoder: the simplest way to think about this is as an example of a translation model — from English sentence to Hindi. Imagine the Encoder part to learn English language details and convert it into a style-independent representation that is taken by the Decoder to add Hindi embellishments and produce the (hopefully) correct output.</p><p>It is always useful to read something and summarize it to commit to memory (and forget 2 days later than you would otherwise). Here is my summary after reading the blog post:</p><ul><li>Multiple encoders stacked atop each other;</li><li>Word embedding + positional encoding fed into the bottommost encoder.</li><li>sentence-length is a parameter and all words of a sentence are fed into the first attention head — each word flows through its own path in the encoder. There are dependencies between these paths in the self-attention layer. The feed-forward layer does not have those dependencies, however, and thus the various paths can be executed in parallel while flowing through the feed-forward layer.</li><li>Each encoder has a self-attention layer and then a Feed-forward NN.</li><li><strong>Self Attention: </strong>Q, K, V — Queries, Keys, and Value vectors are trained. They are used to calculate the relation of a word to other words in the sentence. Q*K gives the relation and passed through softmax, which when multiplied by value vector V keeps only the values we want to focus on (removes irrelevant words).</li><li>softmax(Q*KT/sqrt(dk)) * V = z. z is passed to FFNN.</li><li><strong><em>Multi-headed attention</em></strong>: parallel Q, K, V are trained by randomly initializing them — idea is to capture different kinds of dependencies within words.</li><li>z’s from each attention head is concatenated and then multiplied by another matrix W (per encoder) to give a single z and passed to FFNN.</li><li>The output from final encoder is transformed into K, V matrices for all the decoders (same input) in the decoder-stack. Q is calculated from the decoder below.</li><li>self-attention in decoder looks at only earlier positions (implemented by setting future positions to -inf in the softmax step in the self-attention calculation),</li><li>The decoder begins with a start token, and it takes in a list of previous outputs as inputs, as well as the encoder outputs that contain the attention information from the input. The decoder stops decoding when it generates a token as an output.</li><li><strong>Beam search</strong>: One option for decoder output is that apply softmax on final output and pick the word with highest probability. But if beam_size = 2, then keep the top two choices and run the decoder with both the options and then choose the one which gives lesser error in next round! top_beams = 2 means you want to return that many top final results per sentence.</li><li><strong>Loss function</strong>: compare expected and resulting probability distributions. :D</li></ul><p>Google Tensorflow has excellent documentation for its implementation:<a href="https://www.tensorflow.org/tutorials/text/transformer"> https://www.tensorflow.org/tutorials/text/transformer</a></p><p>[Coming next: How does GPT work?]</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac9a72b6eb07" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why I am going to learn NLP]]></title>
            <link>https://shikha-aggarwal.medium.com/why-i-am-going-to-learn-nlp-eba66d685d22?source=rss-899cfd4c7858------2</link>
            <guid isPermaLink="false">https://medium.com/p/eba66d685d22</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[philosophy]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Shikha Aggarwal]]></dc:creator>
            <pubDate>Thu, 19 Nov 2020 02:21:49 GMT</pubDate>
            <atom:updated>2020-11-30T00:37:25.702Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why I am learning NLP</h3><p>I still need to practice writing a lot of code for various NLP tasks, read a lot of research papers, see the results for myself … before I can call myself reasonably good at NLP. That’s the way I learnt coding — the confidence comes when it comes— but I can still talk about what got me interested.</p><p><strong>Why NLP?</strong></p><p>As Robin Williams best puts it in Dead Poets Society,</p><blockquote>“No matter what people tell you, words and ideas can change the world.”</blockquote><p>Do you value your family above everything else and are ready to live an insipid work life to provide for them? Or are you egoistic like Trump? This is not a moral introspection but simply a reflection that each one of us is a product of the narratives that we have bought over time.</p><p>The text that we read in school formed our value system: political ideology, science vs religion, it is bad to cheat and lie, and good to help others. This happens on a large scale which leads to society-scale behavior patterns and its perception of entertainment and moral ethics. The popularity of delivery startups has led us to believe that ease of getting a thing is to be more valued than enjoying a meal in a restaurant or browsing in a bookstore.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a3OmAoCAiZFq_AT0AQYxkA.jpeg" /><figcaption>Pardon the horrible drawing. Told you I am a text girl!</figcaption></figure><p>And the source of that narrative is changing very rapidly. There is so much volume of text around us that I want either all the text to go away or there be a much more streamlined source. I want to help build this source for us.</p><p>Besides, AI is one of the ways to know more about how we learn, how are mind works, and who we are. Is it possible to represent creativity mathematically? How much are we nurture vs nature because that will decide how much are we able to teach computers?</p><p>But is it wise to just jump into something, pivot my career because NLP is showing a great promise? aka,</p><p><strong>How long have I believed in this?</strong></p><p>I can point to posts from <a href="https://shikha-aggarwal.medium.com/struggle-to-be-shameless-be0b51e3b2ca">my recent past</a>, <a href="https://spilledcolors.wordpress.com/2015/11/10/reading-emancipates/">long ago past</a> where I recount how books that I have read affected me as well as my struggle with writing. A few years ago, I had left my job to write novels — I wanted to share the dreams with others! It has stayed on for more than 8 years. It is more serious than a book affair. I am working towards a Certificate in Creative Writing from University of California, Berkeley. In short, only now I have realised that I want to be part of this aspect of the revolution of the text generation; judging from where I am and ability to contribute to it.</p><p><strong>But starting from scratch is scary.</strong></p><p>Yes. It is a huge field and so many people already have a head start. But that hardly stopped me from learning to solve quadratic equations or coding. The difference was that I probably didn’t know how far behind I lagged.</p><p>I am going to pick a problem that is my motivation: to create a story automatically. As hard it may, it is what motivates me.</p><p><strong>My step 1. Where is the NLP world now?</strong></p><p>GPT, BERT, etc are said to be the state-of-the-art (SOTA) language models today (I am sorry if that statement seems too simplistic or naive but I am not familiar with the domain “lingo” yet). Let’s see what they can do to generate a story.</p><p>[Next post on those findings]</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eba66d685d22" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[San Francisco leaf-count]]></title>
            <link>https://medium.com/swlh/san-francisco-leaf-count-72d06a8e07bf?source=rss-899cfd4c7858------2</link>
            <guid isPermaLink="false">https://medium.com/p/72d06a8e07bf</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[trees]]></category>
            <category><![CDATA[climate-change]]></category>
            <category><![CDATA[san-francisco]]></category>
            <category><![CDATA[leaves]]></category>
            <dc:creator><![CDATA[Shikha Aggarwal]]></dc:creator>
            <pubDate>Fri, 13 Sep 2019 05:28:06 GMT</pubDate>
            <atom:updated>2020-05-12T09:00:37.964Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*rBzf4Ng-wOiu5PBK4TR-XQ.png" /></figure><h3>How does each district fare on greenery?</h3><p>Do you also love trees? Have you thought whether it is a need-based endearment because you realize that you literally cannot live without them, or is it more stoic and you like the calmness and tranquility they exuberate? In any case, for sure they make us happy when we are around them, so I went ahead and did what I do —write code to crunch numbers and found the San Francisco neighborhoods that are most green. <em>Now you know where to go for that evening therapeutic walk or even consider buying a house.</em></p><p>Below you see the list of neighborhoods with most number of trees per square kilometer. Hayes Valley ranks on the top — in case you were wondering why you love strolling down the Hayes street with a person playing a ukulele on a street corner more than walking in SOMA where the tree cover is less than half. By the way, I did not include parks here because I was trying to gauge the general street-greenness of a neighborhood. We will come to parks later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*LDHxAdnLxnT2vgyPsHY2dg.png" /><figcaption>Street-Greenness of neighborhoods: does not include parks</figcaption></figure><p>Despite the Mission Dolores park, the neighborhood appears at the bottom of the list here because this does not account for the parks. It just shows that if you walk around in the streets, there are fewer trees — which is true if you walk down the Valencia street. Here is another picture of the street trees data in all neighborhoods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UL-icSYz8LaegXE8SyPoAA.png" /><figcaption>Street-Greenness of neighborhoods: does not include parks</figcaption></figure><p>To make a judgement on the overall green “accessibility” in a neighborhood, we do want to consider parks. Also, there are green pockets in every neighborhood. So, I created a map that better informs us about those lush areas. It shows a concentration of street trees as well as parks — the lists of which are publicly available on <a href="http://data.sfgov.org/">data.sfgov.org</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5sUUnn5S2RVrdztRoAImSA.png" /></figure><p>Now we have a much better picture of where to go! The above graph shows Presidio National Park as not-green because the park belongs to National Park Service whereas the rest of the parks are the ones maintained by San Francisco Recreation &amp; Parks Department.</p><p>That will be all. Hope this is helpful. Happy strolling!</p><p><strong>Resources used</strong></p><p>Here is my code and data used for the above analysis: <a href="https://github.com/shikha-aggarwal/sf_tree_cover">https://github.com/shikha-aggarwal/sf_tree_cover</a></p><p>In case you are curious about the (legally free!) software and data used for the above analysis, here is a rough list:</p><ul><li>QGIS: A free and open-source cross-platform desktop geographic information system application that supports viewing, editing, and analysis of geospatial data.</li><li>Jupyter Notebook.</li><li>Treepedia project: MIT’s open source initiative to assess green cover from Google street view</li><li>Help from so many people writing answers on stackoverflow and making their priceless projects available online.</li><li>Various Shapefiles (<a href="https://en.wikipedia.org/wiki/Shapefile">https://en.wikipedia.org/wiki/Shapefile</a>) from sources like:</li><li><a href="http://data.sfgov.org/">data.sfgov.org</a></li><li>SF Neighborhoods: <a href="https://data.sfgov.org/Geographic-Locations-and-Boundaries/SF-Find-Neighborhoods/pty2-tcw4">https://data.sfgov.org/Geographic-Locations-and-Boundaries/SF-Find-Neighborhoods/pty2-tcw4</a></li><li>Recreation and Parks Properties: <a href="https://data.sfgov.org/Culture-and-Recreation/Recreation-and-Parks-Properties/wkn6-jn8k">https://data.sfgov.org/Culture-and-Recreation/Recreation-and-Parks-Properties/wkn6-jn8k</a></li><li>County roads: <a href="https://catalog.data.gov/dataset/tiger-line-shapefile-2017-county-san-francisco-county-ca-all-roads-county-based-shapefile">https://catalog.data.gov/dataset/tiger-line-shapefile-2017-county-san-francisco-county-ca-all-roads-county-based-shapefile</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72d06a8e07bf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/san-francisco-leaf-count-72d06a8e07bf">San Francisco leaf-count</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is RNN learning?]]></title>
            <link>https://shikha-aggarwal.medium.com/what-is-rnn-learning-285d7de7800?source=rss-899cfd4c7858------2</link>
            <guid isPermaLink="false">https://medium.com/p/285d7de7800</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[rnn]]></category>
            <dc:creator><![CDATA[Shikha Aggarwal]]></dc:creator>
            <pubDate>Wed, 10 Jul 2019 21:45:44 GMT</pubDate>
            <atom:updated>2019-07-10T21:52:08.475Z</atom:updated>
            <content:encoded><![CDATA[<h3>Intuition into what RNN learns</h3><p>While it is very well documented what the layers in CNN are learning, and most ML experts seem to be aware of it, not many people I talked to, are not comfortable talking about this class of models for text (RNN). So, I want to give some love to the RNNs that they have been missing.</p><p>RNNs are different from other deep learning models in that they “<em>share</em>” the weights being learnt. There are no real layers, which is why it becomes so counter intuitive to visualize what and how they are learning.</p><p>TL;DR — The neurons are trying to learn so many different types of features of language at a character as well as word and sentence level! — a space after a comma, a bracket that is opened will encounter a closed bracket later, tense consistency of a sentence— almost every rule that a new born will come across while learning to write a language. This is why RNNs have one huge set of weights that takes a long time to train.</p><p><strong>Intuition</strong>: In <a href="http://karpathy.github.io/2015/05/21/rnn-effectiveness/">this blog post</a> by Andrej Karpathy, he tries to dissect the neurons from RNN trained on character sequence (not word), with data from Wikipedia. Look at the section titled “Visualizing the predictions and the “neuron” firings in the RNN,” where he shows what some of the neurons are trying to learn. Looking at it, it becomes a tad bit clear that one of the neurons is trying to learn a repetitive text like ‘http://’; others are learning patterns like open brackets need to follow up with closed ones at some point, etc. Some are patterns we are not able to explain — maybe they learn a feature in conjunction with another neuron.</p><p>Now recall that at the end of the day, we are minimizing a cost function using gradient descent in a model — so we are trying to minimize the function in it dimensions. Vaguely, if the cost function in RNN is related to comparing the word output, it will minimize the error in <em>most</em> dimensions — and dimensions are roughly ALL the rules it is learning.</p><p><em>Wow. It feels like we are banking on one set of weights to learn too much. </em>True. We are depending on one set of weights to learn character mapping (space after a comma), as well as relationships between words (use ‘were’ if the subject is plural instead of ‘was’), etc. CNNs seem to have advantage in this that we have multiple layers to handle complexities. From my very preliminary research it is becoming apparent that we do not have that flexibility in RNN yet.</p><p><em>Which is better — character or word-learnt RNN</em>? I haven’t looked into much theoretical detail, but the consensus seems to be that character level requires a lot of parameters to train while the word level is relatively easier. (the character level needs to learn words as well! This of a child who first learns the alphabet as compared to a child who knows all the words.)</p><p><em>Can we help the RNN learn better?</em> I suspect that there is a lot of scope for improvement. Think about a RNN layer that is fed on characters, and a following RNN layer that takes output from the first one and tries to learn a more complicated relationship (eg. between words) using the same sentence. The weights of first network would be updated after each character is fed; and in second after a word is.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=285d7de7800" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Slaughterhouse Five]]></title>
            <link>https://shikha-aggarwal.medium.com/slaughterhouse-five-baea6a7617ba?source=rss-899cfd4c7858------2</link>
            <guid isPermaLink="false">https://medium.com/p/baea6a7617ba</guid>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[books-and-authors]]></category>
            <category><![CDATA[book-review]]></category>
            <category><![CDATA[book-recommendations]]></category>
            <dc:creator><![CDATA[Shikha Aggarwal]]></dc:creator>
            <pubDate>Tue, 11 Jun 2019 20:26:18 GMT</pubDate>
            <atom:updated>2019-06-12T17:07:24.376Z</atom:updated>
            <content:encoded><![CDATA[<p>This is my introduction to Kurt Vonnegut. Surely, this person has seen more in his lifetime than most of us can or even want to.</p><p>The book is based off his experiences in World War II. It also comments upon society’s harmless and indulging relationships that come with preset notions and a set of rules about the roles we take. The narration of the whole story is in a very unreliable tone — by a person who zones in and out of various moments in history and ‘present’. This off-handed story-telling gives you the option to label some of the brazenness of war as unreal even though the preface of the book says that most of the events did happen.</p><p>Writing wise, the story-telling steals the cake. I have no reservations that I would be extremely apprehensive to be a Kurt Vonnegut in person; it would take a true lunatic, throwing away of all societal norms, the cost to be truly yourself is indeed quite high and he has paid it. But at the end of it all, you have the pleasure of calling a book like that your work. *tips hat*</p><p>Please, please read this book.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=baea6a7617ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blogs != Lectures]]></title>
            <link>https://shikha-aggarwal.medium.com/blogs-lectures-c999088a56db?source=rss-899cfd4c7858------2</link>
            <guid isPermaLink="false">https://medium.com/p/c999088a56db</guid>
            <category><![CDATA[learn-right]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[blogs-vs-books]]></category>
            <dc:creator><![CDATA[Shikha Aggarwal]]></dc:creator>
            <pubDate>Mon, 03 Jun 2019 22:22:36 GMT</pubDate>
            <atom:updated>2019-06-04T14:57:56.740Z</atom:updated>
            <content:encoded><![CDATA[<h3>Learning RL: Blogs != Books</h3><p>TL;DR — Do not depend on blog posts to learn theory and basics of a new topic. Look at them to see how people learn, tools they use, get ideas, etc.</p><p>I apologize for writing my previous <a href="https://medium.com/@shikha.aggarval/reinforcement-learning-algorithms-part-1-4108d77b60f4">post on RL Algorithms</a>. As I read more on the topic and searched online to clear my doubts, I realized that the flashy Medium posts by individuals are hogging up the search space without any credibility of the people writing them. I was banking on people who might be new to teaching — sometimes undergrad students who might not have insights or enough overview of the domain to teach.</p><p>Understand that people writing the blogs are people like you and me, who are more techies rather than conversationalists. While I have come across amazingly brilliant people who have put in so much effort building projects, I was confused with the way they explained things in text.</p><p>Case-in-point: I read around 10 posts which tried to explain the difference between Q-Learning and Temporal difference models, and each gave their own version and sometimes, even contradicted each other. I was about to declare myself stupidest person trying to learn AI, when I decided to check-in with Mr. Sutton’s book and see what did it say about it. Exactly 4 lines into 3rd chapter, it became instantly ridiculous-level-clear to me what the difference was. The authors state quite simply,</p><blockquote>“TD learning is a combination of Monte Carlo ideas and dynamic programming (DP) ideas. Like Monte Carlo methods, TD methods can learn directly from raw experience without a model of the environment’s dynamics. Like DP, TD methods update estimates based in part on other learned estimates, without waiting for a final outcome (they bootstrap).”</blockquote><p>Simple, to-the-point. I might still be the stupidest person trying to learn AI, but one who can die peacefully knowing the difference.</p><p>Tip #1: Read this amazing free book called “<a href="http://www.incompleteideas.net/book/the-book-2nd.html">Reinforcement Learning: An Introduction</a>” by Richard S. Sutton and Andrew G. Barto who are known to be pioneers of RL.</p><p>For those who prefer lectures to reading, Fei Fei Li’s course video found in Lecture 14 of the course called ‘<a href="https://www.youtube.com/playlist?list=PL3FW7Lu3i5JvHM8ljYj-zLfQRF3EO8sYv">CS231n: Convolutional Neural Networks for Visual Recognition</a>’ is a good source.</p><p>Tip #2: You can depend on blogs to look at amazing projects implemented by individuals: getting project ideas, see their code, analysis, etc.</p><p>Get inspired by the wonderful work being done by individuals!</p><p>Tip #3: No substitute for coding and verifying the results to learn. Go ahead and implement the algorithms on your own — defining functions for calculating and iterating over Q-values instead of just using libraries. This will raise to many doubts in your head that you need to clear to really understand the nuances between different algorithms. Note, I wanted to start playing with code and see RL algos at work, so I started following a blog post and implement the Q-learning algorithm for playing Blackjack. <a href="https://colab.research.google.com/drive/1gIOUwZvgs1UofQ7oqUAKE24AS_F4A8va">Here</a> is my Colab notebook.</p><p>In lieu of the first point, I have decided not to create more noise by trying to explain my take-away from reading things. I leave that to experts who know the theory inside out and know what the readers need to hear. Changing my approach to writing posts thus, I will be pointing to the links that help me learn and understand specific topics.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c999088a56db" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reinforcement Learning Algorithms (Part 1)]]></title>
            <link>https://shikha-aggarwal.medium.com/reinforcement-learning-algorithms-part-1-4108d77b60f4?source=rss-899cfd4c7858------2</link>
            <guid isPermaLink="false">https://medium.com/p/4108d77b60f4</guid>
            <category><![CDATA[self-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Shikha Aggarwal]]></dc:creator>
            <pubDate>Thu, 23 May 2019 04:27:20 GMT</pubDate>
            <atom:updated>2019-05-29T22:32:34.263Z</atom:updated>
            <content:encoded><![CDATA[<p>If you are searching for Reinforcement learning, it means you are learning RL and have a broad idea what it is.</p><p>Now, we need algorithms — code that will learn the model (policy, possible actions, etc) from sample data. In general, we would start with a policy and try to improve it as we learn from our mistakes.</p><p>Of course there are different algorithms depending on what you are trying to solve and what information we have about the model we are trying to learn.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PfM3lswdBfpG7ZTY1Bdi3w.jpeg" /></figure><p>There are two ways we can learn. The <strong><em>model-based</em></strong> one tries to learn the transition probabilities given any state. This is used when we know with what probability the system will reach state <em>s</em>’ by taking action <em>a</em> in state <em>s</em>. For example, when learning to play chess, we precisely know what the chess board look like if we move the particular pawn. In contrast, if we don’t know this, the alternative is how we learn to play blackjack: relying on trial-and-error to update our knowledge. We start playing and figure out intuitively when it’s a good idea to take a hit or a miss. This is called <strong><em>model-free</em></strong> approach.</p><p>This model-based and model-free is dependent on <em>what</em> we are trying to learn.</p><p>We can also classify the algorithms based on <em>how</em> we learn: do we learn our errors using the latest policy that we have? (<strong>on-policy</strong>) Or do we learn with respect to a policy we started out with? (<strong>off-policy</strong>) My hunch is that eventually we will go with a middle approach where we learn for a few steps with evolving policy and then compare against the initial one to sort of not lose track.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ds5vn42uLAzUbnpvT7wwTw.jpeg" /></figure><p><em>Talk like a Geek tip: </em>When talking about a RL algorithm, specify whether it is a (model-based OR model-free), (on-policy, off-policy) algorithm.</p><p>It is like saying Binary Search is a divide-and-conquer algorithm.</p><p>Ok, but how do we learn a policy?</p><p>Method 1: Think Blackjack. When you start playing it, you just know the rules and you have little idea what your first move would get you into (fine, the 3rd move since first 2 moves usually would be to take a hit). We evaluate (<strong><em>policy evaluation</em></strong> — how likely would I win after this move?) and improve our policies (<strong><em>policy improvement</em></strong> — losing is not always enticing) over time. Playing some games helps you narrow down your technique. This is called <strong>Policy Iteration.</strong></p><p>Method 2: Think solving a Rubik’s cube where we can focus on immediate gains of matching one more block with another of same color. This is called <strong>Value iteration </strong>— we are focussed on the value we are getting out of the move.</p><p>Algorithms:</p><ol><li>Q-Learning is a model-free, off-policy algorithm. *wink*</li><li>SARSA is model-free too, but on-policy</li></ol><p>Similarities:</p><ul><li>Basic principle: Adjust Q-value depending on the error in it. Recall: Q Value is a measure of the overall expected reward assuming the Agent is in state s and performs action a, and then continues playing until the end of the episode following some policy π.</li><li>They both use α (alpha) as the learning rate = how much weight you give to the error at each stage.</li></ul><p>Difference: While SARSA calculates Q-value error using the current policy — i.e. Q value of the action that would be yielded according to the policy we have at hand; Q-learning makes no assumption about the next action. Instead, it used the Q-value of the next state assuming the current action at present state.</p><p>Q-Learning:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/0*AOALmcRExpIIc6H0" /></figure><p>SARSA:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/0*2xZHmErWurDFIaN6" /></figure><p>The Q(s-<em>t+1</em>, a) term in Q-Learning seems a bit off because we are calculating returns for next state based on action we are taking in state <em>s</em>. But intuitively what the term is saying is that we chose an action in present state such that Q is maximized in the next state irrespective of the action chosen there. Strictly speaking, we should have a different notation for it since it is not the action to be taken but that <em>was</em> taken.</p><p><em>[More RL algorithms to be discussed in next post.]</em></p><p>Reading Sources:</p><ul><li><a href="https://spinningup.openai.com/en/latest/spinningup/rl_intro2.html">OpenAI’s lesson</a> was too fast-paced for me. I tried reading it and kept getting distracted for a couple of hours.</li><li>Then I moved to <a href="https://towardsdatascience.com/introduction-to-various-reinforcement-learning-algorithms-i-q-learning-sarsa-dqn-ddpg-72a5e0cb6287">towardsdatascience</a> blog where I found the explanation perfectly suited to my level.</li><li><a href="https://towardsdatascience.com/the-complete-reinforcement-learning-dictionary-e16230b7d24e">RL dictionary</a> for quick back reference.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4108d77b60f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reinforcement Learning — cliffs notes]]></title>
            <link>https://shikha-aggarwal.medium.com/reinforcement-learning-cliffs-notes-3f5dddb544ec?source=rss-899cfd4c7858------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f5dddb544ec</guid>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Shikha Aggarwal]]></dc:creator>
            <pubDate>Wed, 22 May 2019 02:42:33 GMT</pubDate>
            <atom:updated>2019-05-22T21:15:21.417Z</atom:updated>
            <content:encoded><![CDATA[<h3>Reinforcement Learning — cliffs notes</h3><p>Note that I have very basic/intuitive idea about Machine Learning. I don’t want to start reading a course from scratch once more — bored with the same routine of starting from Linear Regression! So, I decided to delve into a topic that I find interesting and go depth-first into things as I come across them. The pitfalls are that there is so much to learn and it can get overwhelming very soon. But then, hopefully it is easier to keep the momentum because I will find out the latest about the area that motivated me to start learning.</p><p>Revision:</p><ul><li>Difference between <strong><em>Matrix and Tensor</em></strong>. Not relevant in most of the context. Like much mathematics, it is mostly about technicality, and the main purpose of this writing is intuition.</li><li><strong><em>Log-likelihood</em></strong> — A method to estimate the parameters of a distribution given a sample to maximize the “likelihood” function, aka, we increase the probability that the given sequence of observation occurred.</li><li><strong><em>Multivariate Gaussian distribution</em></strong> — Distribution that captures dependence of one factor over another. Eg. how is the memory use of a code run related to time taken? Covariance matrix — the diagonal captures the deviation of the parameter itself; the rest of it captures dependence on each other. If the covariance matrix is diagonal, that means the change in a parameter does not affect another — we could as well have independent normal distributions for each of them and people who use the term multivariate for this case are show-offs.</li><li><strong><em>Markov Decision Process</em></strong> — a framework of decision where the agent’s action depends only on the present state and not historical decisions and states. As opposed to real world, where you carry your history in hearts and minds and the air around you.</li></ul><p>Summary:</p><ul><li>Reinforcement learning involves <strong>learning based on rewarding or punishing an action</strong>; as opposed to other techniques where we try to minimize the error in the final answer.</li><li>A <strong>policy</strong> is a rule used by an agent to decide what actions to take based on its current observation. Either μ or π (deterministic or stochastic policy) is what a reinforcement learning algorithm aims to learn.</li><li>To estimate a Categorical policy, we will have Samples (training data) and we will need to find the parameters of the distribution using log likelihood.</li><li>To estimate a Diagonal Gaussian policy, we need to estimate the covariance matrix. Two cases are possible:</li><li>The policy does not depend on present state — there is just a single probability distribution that the agent follows at every damn step. Something like basic version of <em>Game of Life</em> — each living cell has x probability to live, etc. In this case, we just need one neural network to estimate these deviations in actions.</li><li>The policy depends on state in which case we need to estimate a similar deviation matrix for actions for each state.</li><li>A <strong>trajectory, reward function, expected return, etc.</strong> are pretty intuitive ideas.</li><li><strong>Value function</strong>: the expected return if we start in a state or state-action pair, and then act according to a particular policy forever after. Various types are defined — important later, but merely theoretical right now.</li><li><strong>Bellman equation</strong> is a fancy term. Nothing to be feared of — it just says that the value of current state is reward from that state plus the reward from next state — in mathematical form that looks scary. This reward-plus-next-value is also called <em>Bellman backup</em>.</li><li><strong>Advantage function</strong> gives the advantage of a particular action over randomly selecting an action and going on infinitely from there. So, value function of (state, action) minus value function of just the state.</li></ul><p>Now go read the following to speak like a nerd about simple things stated above:</p><ul><li><a href="https://spinningup.openai.com/en/latest/spinningup/rl_intro.html">Open AI’s Spinning up RL intro</a></li><li>Initial parts of <a href="https://lilianweng.github.io/lil-log/2018/02/19/a-long-peek-into-reinforcement-learning.html#key-concepts">this</a> blog post. (Above the section titled ‘Policy Gradient Theorem’)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f5dddb544ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>