<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rohit  Patil</title>
    <description>The latest articles on DEV Community by Rohit  Patil (@rohitpatil5).</description>
    <link>https://dev.to/rohitpatil5</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F172948%2F06eac45f-a636-4912-beaa-42c2855ccca3.jpg</url>
      <title>DEV Community: Rohit  Patil</title>
      <link>https://dev.to/rohitpatil5</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rohitpatil5"/>
    <language>en</language>
    <item>
      <title>Consistent Hashing Simplified</title>
      <dc:creator>Rohit  Patil</dc:creator>
      <pubDate>Wed, 13 Feb 2019 14:42:47 +0000</pubDate>
      <link>https://dev.to/rohitpatil5/consistent-hashing-simplified-44lb</link>
      <guid>https://dev.to/rohitpatil5/consistent-hashing-simplified-44lb</guid>
      <description>&lt;h3&gt;
  
  
  Distributed system problem:-
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;We want to dynamically add/remove cache servers based on usage load.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As these are cache servers, we have a set of keys and values. This could be Memcached, Redis, Hazelcast, Ignite, etc.&lt;/p&gt;

&lt;p&gt;Such setups consist of a pool of caching servers that host many key/value pairs and are used to provide fast access to data originally stored (or computed) elsewhere. For example, to reduce the load on a database server and at the same time improve performance, an application can be designed to first fetch data from the cache servers, and only if it’s not present there — a situation known as &lt;em&gt;cache miss&lt;/em&gt; — resort to the database, running the relevant query and caching the results with an appropriate key, so that it can be found next time it’s needed. We want to distribute the keys across the servers so that we can find them again.&lt;/p&gt;

&lt;p&gt;Our goal is to design a system such that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We should be able to distribute the keys uniformly among the set of “n” servers.&lt;/li&gt;
&lt;li&gt;We should be able to dynamically add or remove a server.&lt;/li&gt;
&lt;li&gt;When we add/remove a server, we need to move the minimal amount of data between the servers.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is the simplest approach:-&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Generate a hash of the key from the incoming data. For example, in python, we would use the hash function.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hashValue = hash(key)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Find out the server to send the data to by taking the modulo of the hashValue using the number of current servers(n):
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;serverIndex = hashValue % n
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now consider the following scenario:-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Imagine we have 4 servers&lt;/li&gt;
&lt;li&gt;Imagine our hash function returns a value from 0 to 7&lt;/li&gt;
&lt;li&gt;We’ll assume that “key0” when passed through our hash function, generates a hash value or 0, “key1” generates 1 and so on.&lt;/li&gt;
&lt;li&gt;The serverIndex for “key0” is 0, “key1” is 1 and so on.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The situation assuming that the key data is uniformly distributed is shown in the image below. We receive 8 pieces of data and our hashing algorithm distributes it evenly across our four database servers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F686%2F1%2AGPaE8st5PCsM3yljFULzGw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F686%2F1%2AGPaE8st5PCsM3yljFULzGw.jpeg"&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;Sharding data across 4 servers&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Problem solved, right? Not quite — there are two major drawbacks with this approach, namely, &lt;strong&gt;Horizontal Scalability&lt;/strong&gt; and &lt;strong&gt;Non-Uniform data distribution&lt;/strong&gt; across servers.&lt;/p&gt;

&lt;h4&gt;
  
  
  Horizontal Scalability:-
&lt;/h4&gt;

&lt;p&gt;The above scheme is not horizontally scalable. If we add or remove servers from the set, all our existing mappings are broken. This is because the value of “n” in our function that calculates the serverIndex changes. The result is that all existing data needs to be remapped and migrated to different servers. This might be a humungous task.&lt;/p&gt;

&lt;p&gt;Let us see what happens when we add another server (server4) to the original pool of server. Notice that we’ll need to update 3 out of the original 4 servers which mean 75% of servers need to be updated.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F715%2F1%2ALGO2Fhv50XKxcK8LA5OqYA.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F715%2F1%2ALGO2Fhv50XKxcK8LA5OqYA.jpeg"&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;Effect of adding a new server to the cluster and the redistribution of the keys&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The effect is more severe when a server goes down as shown below. In this case, we’ll need to update ALL servers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F627%2F1%2A45Yqak6sZHWnnUaRy72q7w.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F627%2F1%2A45Yqak6sZHWnnUaRy72q7w.jpeg"&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;Effect of removing a server from the cluster and the redistribution of the keys&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Data Distribution — Avoiding “Data Hot Spots” in Cluster:-
&lt;/h4&gt;

&lt;p&gt;We cannot expect a uniform distribution of data coming in all the time. There may be many more keys whose hashValue maps to server number 1 than any other servers, in which case server number 1 will become a hotspot for keys.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Consistent hashing allows up to solve both these problems.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  What exactly is Consistent Hashing?
&lt;/h3&gt;

&lt;p&gt;So, how can this problem be solved? We need a distribution scheme that does &lt;em&gt;not&lt;/em&gt; depend directly on the number of servers, so that, when adding or removing servers, the number of keys that need to be relocated is minimized. Consistent hashing facilitates the distribution of data across a set of nodes in such a way that minimizes the re-mapping/ reorganization of data when nodes are added or removed. Here’s how it works:&lt;/p&gt;

&lt;p&gt;Consistent Hashing is a distributed hashing scheme that operates independently of the number of servers or objects in a distributed &lt;em&gt;hash table&lt;/em&gt; by assigning them a position on a &lt;em&gt;hash ring&lt;/em&gt;. This allows servers and objects to scale without affecting the overall system. Here’s how it works:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Creating the Hash Key Space:&lt;/strong&gt; Consider we have a hash function that generates hash values in the range [0,2³²-1). We can represent this as an array of integers with 2³² -1 slot. We’ll call the first slot x0 and the last slot x^n — 1.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F864%2F1%2AaWM8uj5NG1mBAOppaZqVsA.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F864%2F1%2AaWM8uj5NG1mBAOppaZqVsA.jpeg"&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;Linear Hash Key Space&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Representing the hash space as a Ring:&lt;/strong&gt; Imagine that these integers generated after hashing are placed on a ring such that the last value wraps around and forms a cycle.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F594%2F1%2Ab2zrdJkPQciCb-0PSn2HfA.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F594%2F1%2Ab2zrdJkPQciCb-0PSn2HfA.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Placing servers on the HashRing:&lt;/strong&gt; We’re given a list of servers to start with. Using the hash function, we map each server to a specific place on the ring. This simulates placing the four servers into a different place on the ring as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F513%2F1%2AILnfwKrlTfUtXvHvFDJakg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F513%2F1%2AILnfwKrlTfUtXvHvFDJakg.jpeg"&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;Placing servers on a hash ring&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Determining Placement of Keys on Servers:&lt;/strong&gt; To find which server an incoming key resides on, we do the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Calculate the hash for the key using the hash function.&lt;/li&gt;
&lt;li&gt;After hashing the key, we’ll get an integer value which will be contained in the hash space, i.e., it can be mapped to some position in the hash ring. There can be two cases:&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;The hash value maps to a place on the ring which does not have a server. In this case, we travel clockwise on the ring from the point where the key is mapped to until we find the first server. Once we find the first server traveling clockwise on the ring, we insert the key there. The same logic would apply while trying to find a key in the ring.&lt;/li&gt;
&lt;li&gt;The hash value of the key maps directly onto the same hash value of a server — in which case we place it on that server.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Example:&lt;/em&gt; Assume we have 4 incoming keys: key0, key1, key2, key3 and none of them directly maps to the hash value of any of the 4 servers on our hash ring. So we travel clockwise from the point these keys maps to in our ring till we find the first server and insert the key there. This is shown below diagram.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F609%2F1%2A2QliibITykaLRoPAfKlpkg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F609%2F1%2A2QliibITykaLRoPAfKlpkg.jpeg"&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;Key placements on servers in a hash ring&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Adding a server to the Ring:&lt;/strong&gt; If we add another server to the hash Ring, server 4, we’ll need to remap the keys. However, only the keys that reside between server 3 and server 0 needs to be remapped to server 4. &lt;strong&gt;On average, we’ll need to remap only k/n keys, where k is the number of keys and n is the number of servers.&lt;/strong&gt; In modulo based approach we needed to remap nearly all the keys.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The figure below shows the effect of inserting a new server4. As server 4 is between key3 and server4, key3 will be remapped from server0 to server4.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F592%2F1%2Al4LD0o6JzG80sWSoXlYwGw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F592%2F1%2Al4LD0o6JzG80sWSoXlYwGw.jpeg"&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;Effect of adding a server to the hash ring&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Removing a server from the ring:&lt;/strong&gt; A server might go down and consistent hashing scheme ensures that it has minimal effect on the number of keys and servers affected.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As we can see in the figure below, if server0 goes down, only the keys in between server3 and server 0 will need to be remapped to server 1. The rest of the keys are unaffected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F665%2F1%2AT0JUu9g-R3PdYWnhm-g6Nw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F665%2F1%2AT0JUu9g-R3PdYWnhm-g6Nw.jpeg"&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;Effect of removing a server from the hash ring&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hence we can say that &lt;strong&gt;consistent hashing&lt;/strong&gt; successfully solves the &lt;strong&gt;horizontal scalability problem&lt;/strong&gt; by ensuring that every time we scale up or down, we do not have to redistribute all the keys.&lt;/p&gt;

&lt;p&gt;Now let us talk about the second problem of &lt;strong&gt;non-uniform distribution&lt;/strong&gt; of data across servers.&lt;/p&gt;

&lt;p&gt;To ensure object keys are evenly distributed among servers, we need to apply a simple trick: &lt;strong&gt;&lt;em&gt;To assign not one, but many labels to each server on the hash ring.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So instead of having labels server0, server1, server2, server3 we could have, say server00…server03, server10…server13, server20…server23, and server30…server33 all interspersed along the circle.&lt;/p&gt;

&lt;p&gt;As the number of replicas or virtual nodes in the hash ring increase, the key distribution becomes more and more uniform.&lt;/p&gt;

&lt;p&gt;The factor by which to increase the number of labels (server keys), known as &lt;em&gt;weight&lt;/em&gt;, depends on the situation (and may even be different for each server) to adjust the probability of keys ending up on each. For example, if server0 were twice as powerful as the rest, it could be assigned twice as many labels, and as a result, it would end up holding twice as many objects (on average).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F570%2F1%2AmubrfLB-mf_eyY1JGnAOEg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F570%2F1%2AmubrfLB-mf_eyY1JGnAOEg.jpeg"&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;Using virtual nodes/ replication to create a better key distribution in a hash ring&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now imagine server0 is removed. To account for this, we must remove labels server00…server03 from the circle. This results in the object keys formerly adjacent to the deleted labels now being randomly labeled server 3x and sever1x, reassigning them to server3 and server1.&lt;/p&gt;

&lt;p&gt;But what happens with the other object keys, the ones that originally belonged in server3 and server1? Nothing! That’s the beauty of it: The absence of server0 labels does not affect those keys in any way. So, removing a server results in its object keys being randomly reassigned to the rest of the servers, leaving all other keys untouched.&lt;/p&gt;

&lt;p&gt;And this is how &lt;strong&gt;consistent hashing&lt;/strong&gt; solves the &lt;strong&gt;non-uniform distribution&lt;/strong&gt; problem.&lt;/p&gt;

&lt;h3&gt;
  
  
  References:-
&lt;/h3&gt;

&lt;p&gt;I found that the authors never published an extended version with proofs, even though they said they would. The closest thing to an extended paper is,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.17.8503&amp;amp;rep=rep1&amp;amp;type=pdf" rel="noopener noreferrer"&gt;Relieving Hot Spots on the World Wide Web&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thank you for reading. &lt;a href="https://twitter.com/Rohitpatil5" rel="noopener noreferrer"&gt;You can find me on Twitter @Rohitpatil5&lt;/a&gt;, or connect with me on &lt;a href="https://www.linkedin.com/in/rohitrpatil/" rel="noopener noreferrer"&gt;LinkedIn.&lt;/a&gt;&lt;/p&gt;




</description>
      <category>hashing</category>
      <category>consistenthashing</category>
      <category>distributedsystems</category>
      <category>caching</category>
    </item>
    <item>
      <title>The Matrix Calculus You Need For Deep Learning (Notes from a paper by Terence Parr and Jeremy…</title>
      <dc:creator>Rohit  Patil</dc:creator>
      <pubDate>Tue, 27 Feb 2018 12:44:59 +0000</pubDate>
      <link>https://dev.to/rohitpatil5/the-matrix-calculus-you-need-for-deep-learning-notes-from-a-paper-by-terence-parr-and-jeremy-59n7</link>
      <guid>https://dev.to/rohitpatil5/the-matrix-calculus-you-need-for-deep-learning-notes-from-a-paper-by-terence-parr-and-jeremy-59n7</guid>
      <description>&lt;h3&gt;
  
  
  The Matrix Calculus You Need For Deep Learning (Notes from a paper by &lt;a href="http://parrt.cs.usfca.edu/"&gt;Terence Parr&lt;/a&gt; and &lt;a href="http://www.fast.ai/about/#jeremy"&gt;Jeremy Howard&lt;/a&gt;)
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zMKIKCQg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Al_ZFM3-vJMBVcZacHwCX-Q.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zMKIKCQg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Al_ZFM3-vJMBVcZacHwCX-Q.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Table of Contents&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://medium.com/p/4f4263b7bb8#48c0"&gt;Review: Scalar derivative rules&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/p/4f4263b7bb8#d5f1"&gt;Introduction to vector calculus and partial derivatives&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/p/4f4263b7bb8#3c66"&gt;Matrix calculus&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/p/4f4263b7bb8#efec"&gt;Generalization of the Jacobian&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/p/4f4263b7bb8#59c5"&gt;Derivatives of vector element-wise binary operators&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/p/4f4263b7bb8#641f"&gt;Vector sum reduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/p/4f4263b7bb8#ada3"&gt;The Chain Rules&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/p/4f4263b7bb8#3788"&gt;Resources&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Jeremy’s courses show how to become a world-class &lt;em&gt;deep learning practitioner&lt;/em&gt; with only a minimal level of scalar calculus, thanks to leveraging the automatic differentiation built in to modern deep learning libraries. But if you really want to really understand what’s going on under the hood of these libraries, and grok academic papers discussing the latest advances in model training techniques, you’ll need to understand certain bits of the field of matrix calculus.&lt;/p&gt;

&lt;h3&gt;
  
  
  Review: Scalar derivative rules
&lt;/h3&gt;

&lt;p&gt;Hopefully you remember some of these main scalar derivative rules. If your memory is a bit fuzzy on this, have a look at &lt;a href="https://www.khanacademy.org/math/ap-calculus-ab/ab-derivative-rules"&gt;Khan academy video on scalar derivative rules&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xrQOMWtU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AZR50K2cDpl1um4S-aOeWQw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xrQOMWtU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AZR50K2cDpl1um4S-aOeWQw.png" alt=""&gt;&lt;/a&gt;Basic rules of derivatives&lt;/p&gt;

&lt;p&gt;There are other rules for trigonometry, exponential, etc., which you can find at &lt;a href="https://www.khanacademy.org/math/differential-calculus"&gt;Khan Academy differential calculus course&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction to vector calculus and partial derivatives
&lt;/h3&gt;

&lt;p&gt;Neural network layers are not single functions of a single parameter, &lt;strong&gt;&lt;em&gt;f(x)&lt;/em&gt;&lt;/strong&gt;. So, let’s move on to functions of multiple parameters such as &lt;strong&gt;&lt;em&gt;f(x,y)&lt;/em&gt;&lt;/strong&gt;. For example, what is the derivative of xy (i.e., the multiplication of x and y)?&lt;/p&gt;

&lt;p&gt;Well, it depends on whether we are changing &lt;em&gt;x&lt;/em&gt; or &lt;em&gt;y&lt;/em&gt;. We compute derivatives with respect to one variable (parameter) at a time, giving us two different &lt;em&gt;partial derivatives&lt;/em&gt; for this two-parameter function (one for &lt;em&gt;x&lt;/em&gt; and one for &lt;em&gt;y&lt;/em&gt;). Instead of using operator d/dx, the partial derivative operator is &lt;strong&gt;∂/ ∂x&lt;/strong&gt; (a stylized &lt;em&gt;d&lt;/em&gt; and not the Greek letter δ ). So &lt;strong&gt;∂(xy)/ ∂x&lt;/strong&gt; and &lt;strong&gt;∂(xy)/ ∂y&lt;/strong&gt; are the partial derivatives of &lt;em&gt;xy&lt;/em&gt;; often, these are just called the &lt;em&gt;partials&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The partial derivative with respect to &lt;em&gt;x&lt;/em&gt; is just the usual scalar derivative, simply treating any other variable in the equation as a constant. Consider function f(x,y) = 3x²y. The partial derivative with respect to &lt;em&gt;x&lt;/em&gt; is written &lt;strong&gt;∂(&lt;/strong&gt;3x²y*&lt;em&gt;)/ ∂x.&lt;/em&gt;* There are three constants from the perspective of &lt;strong&gt;∂/ ∂x&lt;/strong&gt; : 3, 2, and &lt;em&gt;y&lt;/em&gt;. Therefore, ∂(3x²y)/ ∂x = 3y∂(x²)/ ∂x = 3y(2x) = 6xy. The partial derivative with respect to &lt;em&gt;y&lt;/em&gt; treats &lt;em&gt;x&lt;/em&gt; like a constant and we get ∂(3x²y)/ ∂y = 3x². You can learn more on &lt;a href="https://www.khanacademy.org/math/multivariable-calculus/multivariable-derivatives/partial-derivative-and-gradient-articles/a/introduction-to-partial-derivatives"&gt;Khan Academy video on partials&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So from above example if f(x,y) = 3x²y, then&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RGg7FVdZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/657/1%2A8a9yL0FQmO70v-Juo5c3Bg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RGg7FVdZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/657/1%2A8a9yL0FQmO70v-Juo5c3Bg.png" alt=""&gt;&lt;/a&gt;&lt;em&gt;Gradient&lt;/em&gt; of f(x,y)&lt;/p&gt;

&lt;p&gt;So the &lt;strong&gt;&lt;em&gt;gradient of f(x,y) is simply a vector of its partial.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Matrix calculus
&lt;/h3&gt;

&lt;p&gt;When we move from derivatives of one function to derivatives of many functions, we move from the world of vector calculus to matrix calculus. Let us bring one more function g(x,y) = 2x + y⁸. So gradient of g(x,y) is&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lBc7kWkm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/194/1%2AIUpOnL8zNi_fPcDKcFP3BQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lBc7kWkm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/194/1%2AIUpOnL8zNi_fPcDKcFP3BQ.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Gradient vectors organize all of the partial derivatives for a specific scalar function. If we have two functions, we can also organize their gradients into a matrix by stacking the gradients. When we do so, we get the &lt;strong&gt;&lt;em&gt;Jacobian matrix&lt;/em&gt;&lt;/strong&gt; (or just the &lt;strong&gt;&lt;em&gt;Jacobian&lt;/em&gt;&lt;/strong&gt; ) where the gradients are rows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_DB94Oyq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/549/1%2A7xKV9D7qXX44GQQbvYlBgA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_DB94Oyq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/549/1%2A7xKV9D7qXX44GQQbvYlBgA.png" alt=""&gt;&lt;/a&gt;&lt;a href="https://en.wikipedia.org/wiki/Matrix_calculus#Layout_conventions"&gt;Numerator layout&lt;/a&gt; of Jacobian&lt;/p&gt;

&lt;h3&gt;
  
  
  Generalization of the Jacobian
&lt;/h3&gt;

&lt;p&gt;To define the Jacobian matrix more generally, let’s combine multiple parameters into a single vector argument: &lt;em&gt;f&lt;/em&gt;(&lt;em&gt;x,y,z&lt;/em&gt;) =&amp;gt; &lt;em&gt;f&lt;/em&gt;( &lt;strong&gt;x&lt;/strong&gt; ). Lowercase letters in bold font such as &lt;strong&gt;x&lt;/strong&gt; are vectors and those in italics font like &lt;em&gt;x&lt;/em&gt; are scalars. &lt;em&gt;xi&lt;/em&gt; is the ith element of vector &lt;strong&gt;x&lt;/strong&gt; and is in italics because a single vector element is a scalar. We also have to define an orientation for vector &lt;strong&gt;x&lt;/strong&gt;. We’ll assume that all vectors are vertical by default of size &lt;em&gt;n&lt;/em&gt; X 1:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qIod3W29--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/127/1%2ATnlD_RDMVQhGizRLp3jd-Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qIod3W29--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/127/1%2ATnlD_RDMVQhGizRLp3jd-Q.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With multiple scalar-valued functions, we can combine them all into a vector just like we did with the parameters. Let &lt;strong&gt;y = f(x) b&lt;/strong&gt;e a vector of &lt;em&gt;m&lt;/em&gt; scalar-valued functions that each take a vector &lt;strong&gt;x&lt;/strong&gt; of length n= | &lt;strong&gt;x&lt;/strong&gt; | where | &lt;strong&gt;x&lt;/strong&gt; | is the cardinality (count) of elements in &lt;strong&gt;x&lt;/strong&gt;. Each &lt;em&gt;fi&lt;/em&gt; function within &lt;strong&gt;f&lt;/strong&gt; returns a scalar just as in the previous section&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ECo0ePJI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/177/1%2AwyqevFkocbibjZjs1E3MOA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ECo0ePJI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/177/1%2AwyqevFkocbibjZjs1E3MOA.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Generally speaking, though, the Jacobian matrix is the collection of all &lt;strong&gt;&lt;em&gt;m&lt;/em&gt;&lt;/strong&gt; X &lt;strong&gt;&lt;em&gt;n&lt;/em&gt;&lt;/strong&gt; possible partial derivatives (&lt;em&gt;m&lt;/em&gt; rows and &lt;em&gt;n&lt;/em&gt; columns), which is the stack of &lt;em&gt;m&lt;/em&gt; gradients with respect to  &lt;strong&gt;x&lt;/strong&gt; :&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Er8rgAs6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/762/1%2Af75-0xoIgirN-kkL2d_vEg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Er8rgAs6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/762/1%2Af75-0xoIgirN-kkL2d_vEg.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Derivatives of vector element-wise binary operators
&lt;/h3&gt;

&lt;p&gt;By “element-wise binary operations” we simply mean applying an operator to the first item of each vector to get the first item of the output, then to the second items of the inputs for the second item of the output, and so forth.We can generalize the element-wise binary operations with notation y= f(w) O g(x) where &lt;strong&gt;&lt;em&gt;m&lt;/em&gt;&lt;/strong&gt; = &lt;strong&gt;&lt;em&gt;n&lt;/em&gt;&lt;/strong&gt; = | &lt;strong&gt;&lt;em&gt;y&lt;/em&gt;&lt;/strong&gt; | = | &lt;strong&gt;&lt;em&gt;w&lt;/em&gt;&lt;/strong&gt; | = | &lt;strong&gt;&lt;em&gt;x&lt;/em&gt;&lt;/strong&gt; |. The O symbol represents any element-wise operator (such as +) and not the o function composition operator.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gSwEkR-2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A6SVHGcQcijq6aEYUoC_yZw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gSwEkR-2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A6SVHGcQcijq6aEYUoC_yZw.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s quite a furball, but fortunately the Jacobian is very often a diagonal matrix, a matrix that is zero everywhere but the diagonal.&lt;/p&gt;

&lt;h3&gt;
  
  
  Vector sum reduction
&lt;/h3&gt;

&lt;p&gt;Summing up the elements of a vector is an important operation in deep learning, such as the network loss function, but we can also use it as a way to simplify computing the derivative of vector dot product and other operations that reduce vectors to scalars.&lt;/p&gt;

&lt;p&gt;Let &lt;strong&gt;y=sum(f(x))&lt;/strong&gt; = Σ &lt;strong&gt;&lt;em&gt;fi&lt;/em&gt;&lt;/strong&gt; ( &lt;strong&gt;x&lt;/strong&gt; ). Notice we were careful here to leave the parameter as a vector &lt;strong&gt;x&lt;/strong&gt; because each function &lt;em&gt;fi&lt;/em&gt; could use all values in the vector, not just &lt;em&gt;xi&lt;/em&gt;. The sum is over the &lt;strong&gt;results&lt;/strong&gt; of the function and not the parameter. The gradient ( &lt;strong&gt;1&lt;/strong&gt; X &lt;strong&gt;&lt;em&gt;n&lt;/em&gt;&lt;/strong&gt; Jacobian) of vector summation is:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nPP6mBzr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/960/1%2A-MEhl1gPbjiIjXyla9C3wQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nPP6mBzr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/960/1%2A-MEhl1gPbjiIjXyla9C3wQ.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Chain Rules
&lt;/h3&gt;

&lt;p&gt;We can’t compute partial derivatives of very complicated functions using just the basic matrix calculus rules. Part of our goal here is to clearly define and name three different chain rules and indicate in which situation they are appropriate.&lt;/p&gt;

&lt;p&gt;The chain rule is conceptually a divide and conquer strategy (like Quicksort) that breaks complicated expressions into sub-expressions whose derivatives are easier to compute. Its power derives from the fact that we can process each simple sub-expression in isolation yet still combine the intermediate results to get the correct overall result.&lt;/p&gt;

&lt;p&gt;The chain rule comes into play when we need the derivative of an expression composed of nested subexpressions. For example, we need the chain rule when confronted with expressions like d(sin(x²))/dx.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://m.wolframalpha.com/input/?i=chain+rule"&gt;&lt;strong&gt;Single-variable chain rule&lt;/strong&gt;&lt;/a&gt; ** :-** Chain rules are typically defined in terms of nested functions, such as &lt;strong&gt;&lt;em&gt;y&lt;/em&gt;&lt;/strong&gt; = &lt;strong&gt;&lt;em&gt;f&lt;/em&gt;(&lt;em&gt;u&lt;/em&gt;)&lt;/strong&gt; where &lt;strong&gt;&lt;em&gt;u&lt;/em&gt;= &lt;em&gt;g&lt;/em&gt;(&lt;em&gt;x&lt;/em&gt;) so &lt;em&gt;y&lt;/em&gt;= &lt;em&gt;f&lt;/em&gt;(&lt;em&gt;g&lt;/em&gt;(&lt;em&gt;x&lt;/em&gt;))&lt;/strong&gt; for single-variable chain rules.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cNfWIG2n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/160/1%2Au3k7gS3vAPEXukvkWmyDzg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cNfWIG2n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/160/1%2Au3k7gS3vAPEXukvkWmyDzg.png" alt=""&gt;&lt;/a&gt;Formulation of the single-variable chain rule&lt;/p&gt;

&lt;p&gt;To deploy the single-variable chain rule, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Introduce intermediate variables for nested sub-expressions and sub-expressions for both binary and unary operators; example, X is binary, &lt;strong&gt;&lt;em&gt;sin (x)&lt;/em&gt;&lt;/strong&gt; and other trigonometric functions are usually unary because there is a single operand. This step normalizes all equations to single operators or function applications.&lt;/li&gt;
&lt;li&gt;Compute derivatives of the intermediate variables with respect to their parameters.&lt;/li&gt;
&lt;li&gt;Combine all derivatives of intermediate variables by multiplying them together to get the overall result.&lt;/li&gt;
&lt;li&gt;Substitute intermediate variables back in if any are referenced in the derivative equation.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Single-variable total-derivative chain rule :-&lt;/strong&gt; The total derivative assumes all variables are potentially codependent whereas the partial derivative assumes all variables but &lt;em&gt;x&lt;/em&gt; are constants.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uJDjhT8v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/905/1%2ANxfy9U1Eh7_skLznwc3U-w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uJDjhT8v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/905/1%2ANxfy9U1Eh7_skLznwc3U-w.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This chain rule that takes into consideration the total derivative degenerates to the single-variable chain rule when all intermediate variables are functions of a single variable.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A word of caution about terminology on the web. Unfortunately, the chain rule given in this section, based upon the total derivative, is universally called “multivariable chain rule” in calculus discussions, which is highly misleading! Only the intermediate variables are multivariate functions.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Vector chain rule :-&lt;/strong&gt; Vector chain rule for vectors of functions and a single parameter mirrors the single-variable chain rule.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If &lt;strong&gt;&lt;em&gt;y&lt;/em&gt;= &lt;em&gt;f&lt;/em&gt;(&lt;em&gt;g&lt;/em&gt;(&lt;em&gt;x&lt;/em&gt;))&lt;/strong&gt; and &lt;strong&gt;x&lt;/strong&gt; is a vector &lt;strong&gt;.&lt;/strong&gt; The derivative of vector &lt;strong&gt;y&lt;/strong&gt; with respect to scalar &lt;em&gt;x&lt;/em&gt; is a vertical vector with elements computed using the single-variable total-derivative chain rule.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CBYKWzVO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/412/1%2AjtPtLuhQTBVK_0Be5rIpXQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CBYKWzVO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/412/1%2AjtPtLuhQTBVK_0Be5rIpXQ.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The goal is to convert the above vector of scalar operations to a vector operation. So the above RHS matrix can also be implemented as a product of vector multiplication.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ewqf-cau--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/317/1%2AAIrI5dTFm_X_ybGL0UqayA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ewqf-cau--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/317/1%2AAIrI5dTFm_X_ybGL0UqayA.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That means that the Jacobian is the multiplication of two other Jacobians. To make this formula work for multiple parameters or vector &lt;strong&gt;x&lt;/strong&gt; , we just have to change &lt;em&gt;x&lt;/em&gt; to vector &lt;strong&gt;x&lt;/strong&gt; in the equation. The effect is that &lt;strong&gt;∂g/ ∂x&lt;/strong&gt; and the resulting Jacobian, *&lt;em&gt;∂f/ ∂x *&lt;/em&gt; , are now matrices instead of vertical vectors. Our complete &lt;em&gt;vector chain rule&lt;/em&gt; is:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nXHdyB7c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/223/1%2AsGJplnNYP7leOS-lNmRNFg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nXHdyB7c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/223/1%2AsGJplnNYP7leOS-lNmRNFg.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Please note here that matrix multiply does not commute, the order of (**∂f/ ∂x)(∂g/ ∂x) **matters.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For completeness, here are the two Jacobian components :-&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vO-bS5EV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/666/1%2Ag5ph9kQOynRPVYfr1nYytA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vO-bS5EV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/666/1%2Ag5ph9kQOynRPVYfr1nYytA.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;where &lt;strong&gt;&lt;em&gt;m&lt;/em&gt;&lt;/strong&gt; = | &lt;strong&gt;&lt;em&gt;f&lt;/em&gt;&lt;/strong&gt; |, &lt;strong&gt;&lt;em&gt;n&lt;/em&gt;&lt;/strong&gt; = | &lt;strong&gt;&lt;em&gt;x&lt;/em&gt;&lt;/strong&gt; | and &lt;strong&gt;&lt;em&gt;k&lt;/em&gt;&lt;/strong&gt; = | &lt;strong&gt;&lt;em&gt;g&lt;/em&gt;&lt;/strong&gt; |. The resulting Jacobian is &lt;strong&gt;&lt;em&gt;m&lt;/em&gt;&lt;/strong&gt; X &lt;strong&gt;&lt;em&gt;n&lt;/em&gt;&lt;/strong&gt;. (an &lt;strong&gt;&lt;em&gt;m&lt;/em&gt;&lt;/strong&gt; X &lt;strong&gt;&lt;em&gt;k&lt;/em&gt;&lt;/strong&gt; matrix multiplied by a &lt;strong&gt;&lt;em&gt;k&lt;/em&gt;&lt;/strong&gt; X &lt;strong&gt;_n _&lt;/strong&gt; matrix).&lt;/p&gt;

&lt;p&gt;We can simplify further because, for many applications, the Jacobians are square ( &lt;strong&gt;&lt;em&gt;m&lt;/em&gt;&lt;/strong&gt; = &lt;strong&gt;&lt;em&gt;n&lt;/em&gt;&lt;/strong&gt; ) and the off-diagonal entries are zero.&lt;/p&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;p&gt;1.The original &lt;a href="http://parrt.cs.usfca.edu/doc/matrix-calculus/index.html#sec3"&gt;paper&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;There are some online tools which can differentiate a matrix for you:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.wolframalpha.com/input/?i=D%5B%7Bx%5E2,+x%5E3%7D.%7B%7B1,2%7D,%7B3,4%7D%7D.%7Bx%5E2,+x%5E3%7D,+x%5D"&gt;Wolfram Alpha&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.matrixcalculus.org/"&gt;Matrix calculus Differentiator.&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;More &lt;a href="https://atmos.washington.edu/~dennis/MatrixCalculus.pdf"&gt;matrix calculus&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IZl3bwWV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/201/1%2AxhCj5o5sYa_8VBUw_mR_Xg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IZl3bwWV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/201/1%2AxhCj5o5sYa_8VBUw_mR_Xg.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>calculus</category>
      <category>mathematics</category>
      <category>deeplearning</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>How to use TensorFlow Object Detection API On Windows</title>
      <dc:creator>Rohit  Patil</dc:creator>
      <pubDate>Wed, 31 Jan 2018 21:25:37 +0000</pubDate>
      <link>https://dev.to/rohitpatil5/how-to-use-tensorflow-object-detection-api-on-windows-21b4</link>
      <guid>https://dev.to/rohitpatil5/how-to-use-tensorflow-object-detection-api-on-windows-21b4</guid>
      <description>&lt;p&gt;Around July 2017, TensorFlow’s Object Detection API was released. The TensorFlow Object Detection API is an open source framework built on top of TensorFlow that makes it easy to construct, train and deploy object detection models.&lt;/p&gt;

&lt;p&gt;What makes this API huge is that unlike other models like YOLO, SSD, you do not need a complex hardware setup to run it.&lt;/p&gt;

&lt;p&gt;They have published a paper titled &lt;a href="https://arxiv.org/pdf/1611.10012.pdf"&gt;&lt;strong&gt;Speed/accuracy trade-offs for modern convolutional object detectors&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;.&lt;/strong&gt; Here they discuss various architecture available for object detection like YOLO, Faster R-CNN, SSD and R-FCN.&lt;/p&gt;

&lt;p&gt;This API is capable of identifying many types of objects like cars, pedestrians, person, kite, dog and many more. You can find the whole list &lt;a href="https://github.com/tensorflow/models/tree/master/research/object_detection/data"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I have used this API, for detecting traffic signal in a live video stream for capstone project of Udacity’s self-driving car nanodegree program. In this project we had to run the Carla (self-driving car of Udacity) on the road.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Yf_EjmWY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/347/1%2AQWfzSzTFabLWSginzECvDQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Yf_EjmWY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/347/1%2AQWfzSzTFabLWSginzECvDQ.png" alt=""&gt;&lt;/a&gt;Output from the simulator’s video feed.&lt;/p&gt;

&lt;p&gt;Let’s begin the setup.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Clone the &lt;a href="https://github.com/tensorflow/models"&gt;tensorflow-model repository&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The main API documentation is at &lt;a href="https://github.com/tensorflow/models/tree/master/research/object_detection"&gt;https://github.com/tensorflow/models/tree/master/research/object_detection&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Install tensorflow.&lt;/li&gt;
&lt;/ol&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# For CPU
pip install tensorflow
# For GPU
pip install tensorflow-gpu
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Install all other dependencies&lt;/li&gt;
&lt;/ol&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install pillow
pip install lxml
pip install jupyter
pip install matplotlib
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Download Google Protobuf &lt;a href="https://github.com/google/protobuf"&gt;https://github.com/google/protobuf&lt;/a&gt; Windows v3.4.0 release “protoc-3.4.0-win32.zip”&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Extract the Protobuf download to Program Files, specifically&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Program Files\protoc-3.4.0-win32
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Now cd into models\research.&lt;/li&gt;
&lt;/ol&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd path\to\models\research
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Execute the protobuf compile&lt;/li&gt;
&lt;/ol&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;“C:\Program Files\protoc-3.4.0-win32\bin\protoc.exe” object\_detection/protos/\*.proto --python\_out=.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This is the most important step in the installation process.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Now navigate to models\research\object_detection\protos and and verify the .py files were created successfully as a result of the compilation. (only the .proto files were there to begin with)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;cd to \models\research\object_detection. Open the jupyter notebook object_detection_tutorial.ipynb. Here you can play with the API.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Problem you will probably face :
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;If you move the notebook to any other directory, and run it and you will get an error&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ModuleNotFoundError: No module named 'utils'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Source of this error are these two lines in the code.&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from utils import label\_map\_util
from utils import visualization\_utils as vis\_util
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This error is because we are yet to inform Python how to find the utils directory that these lines use.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Issue Resolution :
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Go to System -&amp;gt; Advanced system settings -&amp;gt; Environment Variables -&amp;gt; New, and add a variable with the name PYTHON_PATH and these values:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5L12vPfz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/806/1%2ASKX64WwYgCYKXToHPZusXg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5L12vPfz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/806/1%2ASKX64WwYgCYKXToHPZusXg.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In system variables, edit PATH and add %PYTHON_PATH%.&lt;/li&gt;
&lt;li&gt;You will need to restart the system and then you are free to use this code anywhere in the system.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Some output samples
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sHhEDB8b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1000/1%2Al33kFqOZt7ti98kAKLwadQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sHhEDB8b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1000/1%2Al33kFqOZt7ti98kAKLwadQ.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_VowbTiN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/655/1%2A62JsN-0BZ2rl1QdhNLSN8A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_VowbTiN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/655/1%2A62JsN-0BZ2rl1QdhNLSN8A.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For experimenting with this API, I used my webcam and mobile’s camera. I used &lt;a href="https://play.google.com/store/apps/details?id=com.pas.webcam&amp;amp;hl=en"&gt;IP Webcam Android App&lt;/a&gt; for interfacing the mobile camera. You can checkout the repository.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/rohts-patil/TensorFlow-Object-Detection-API-On-Live-Video-Feed"&gt;rohts-patil/TensorFlow-Object-Detection-API-On-Live-Video-Feed&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you for reading. &lt;a href="https://twitter.com/Rohitpatil5"&gt;You can find me on Twitter @Rohitpatil5&lt;/a&gt;, or connect with me on &lt;a href="https://www.linkedin.com/in/rohitrpatil/"&gt;LinkedIn.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python3</category>
      <category>deeplearning</category>
      <category>computervision</category>
      <category>objectdetection</category>
    </item>
    <item>
      <title>Basic Mathematics for Machine Learning</title>
      <dc:creator>Rohit  Patil</dc:creator>
      <pubDate>Tue, 09 Jan 2018 07:11:57 +0000</pubDate>
      <link>https://dev.to/rohitpatil5/basic-mathematics-for-machine-learning-d2a</link>
      <guid>https://dev.to/rohitpatil5/basic-mathematics-for-machine-learning-d2a</guid>
      <description>&lt;p&gt;&lt;a href="https://medium.com/@rohitrpatil/the-matrix-calculus-you-need-for-deep-learning-notes-from-a-paper-by-terence-parr-and-jeremy-4f4263b7bb8"&gt;&lt;em&gt;EDIT :- For calculus go through my post on matrix calculus.&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are many reasons why mathematics is important for machine learning. Some of them are below:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Selecting the right algorithm which includes giving considerations to accuracy, training time, model complexity, number of parameters and number of features.&lt;/li&gt;
&lt;li&gt;Choosing parameter settings and validation strategies.&lt;/li&gt;
&lt;li&gt;Identifying underfitting and overfitting by understanding the Bias-Variance tradeoff.&lt;/li&gt;
&lt;li&gt;Estimating the right confidence interval and uncertainty.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VJtCYYCN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AeUYIqyg9aomn55O-Q5XRVg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VJtCYYCN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AeUYIqyg9aomn55O-Q5XRVg.png" alt=""&gt;&lt;/a&gt;What really is used!&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What are the best resources for learning?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D0vz6psG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/856/1%2AODJPbEcabUyMrMPnCeOYKg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D0vz6psG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/856/1%2AODJPbEcabUyMrMPnCeOYKg.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have tried to summarized mathematics taught in above both resources. So lets begin!&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Scalars, Vectors, Matrices and Tensors :&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;*&lt;em&gt;Scalars *&lt;/em&gt; : A scalar is just a single number.&lt;/li&gt;
&lt;li&gt;*&lt;em&gt;Vectors *&lt;/em&gt; : A vector is an array of numbers. The numbers are arranged in order. We can identify each individual number by its index in that ordering. &lt;em&gt;x=[x1 x2 x3 …. xn].&lt;/em&gt; We can think of vectors as identifying points in space, with each element giving the coordinate along a diﬀerent axis. Sometimes we need to index a set of elements of a vector. In this case, we deﬁne a set containing the indices and write the set as a subscript. For example, to access &lt;em&gt;x1, x3 and x6&lt;/em&gt; we deﬁne the set &lt;em&gt;S&lt;/em&gt; ={1,3,6} and write &lt;em&gt;xs.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;*&lt;em&gt;Matrices *&lt;/em&gt; : A matrix is a 2-D array of numbers, so each element is identiﬁed by two indices instead of just one.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z4pEN0OO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/166/1%2AYIZqGzeRxmfiFW-fj8qp-Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z4pEN0OO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/166/1%2AYIZqGzeRxmfiFW-fj8qp-Q.png" alt=""&gt;&lt;/a&gt;When we need to explicitly identify the elements of a matrix, we write them as an array enclosed in square brackets&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;transpose&lt;/strong&gt; of a matrix is the mirror image of the matrix across a diagonal line, called the main diagonal, running down and to the right, starting from its upper left corner.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6YGbQPcc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/397/1%2AIfvcwFO2FLdr-xsE--BRCw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6YGbQPcc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/397/1%2AIfvcwFO2FLdr-xsE--BRCw.png" alt=""&gt;&lt;/a&gt;Transpose of a matrix&lt;/p&gt;

&lt;p&gt;We can add matrices to each other, as long as they have the same shape, just by adding their corresponding elements: C = A + B where &lt;em&gt;Ci,j = Ai,j+ Bi,j.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We allow the addition of matrix and a vector, yielding another matrix: C=A+b, where &lt;em&gt;Ci,j = Ai,j +bj&lt;/em&gt;. In other words, the vector b is added to each row of the matrix. This shorthand eliminates the need to deﬁne a matrix with b copied into each row before doing the addition. This implicit copying of b to many locations is called &lt;strong&gt;&lt;em&gt;broadcasting&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tensors :&lt;/strong&gt; An array of numbers arranged on a regular grid with a variable number of axes is known as a tensor.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Multiplying Matrices and Vectors:
&lt;/h3&gt;

&lt;p&gt;The matrix product of matrices A and B is a third matrix C. In order for this product to be deﬁned, A must have the same number of columns as B has rows. If A is of shape m × n and B is of shape n × p, then C is of shape m × p.&lt;/p&gt;

&lt;p&gt;The product operation is deﬁned by&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1MPXwn73--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/195/1%2AUwUwRGXR4K2ulM7yLLaVfg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1MPXwn73--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/195/1%2AUwUwRGXR4K2ulM7yLLaVfg.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The matrix multiplication is distributive, associative but not commutative (the condition AB =BA does not always hold), unlike scalar multiplication.&lt;/p&gt;

&lt;p&gt;For learning more you can go through this course offered by MIT Courseware (Prof. Gilbert Strang).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ocw.mit.edu/courses/mathematics/18-06-linear-algebra-spring-2010/"&gt;Linear Algebra&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Probability Theory:
&lt;/h3&gt;

&lt;p&gt;Probability theory is a mathematical framework for representing uncertain statements. It provides a means of quantifying uncertainty as well as axioms for deriving new uncertain statements.&lt;/p&gt;

&lt;p&gt;Let us understand some of the terminologies used in probability theory:-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;*&lt;em&gt;Random Variables *&lt;/em&gt; : A random variable is a variable that can take on diﬀerent values randomly. They may be continuous or discrete. A discrete random variable is one that has a ﬁnite or countably inﬁnite number of states. A continuous random variable is associated with a real value.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Probability Distributions&lt;/strong&gt;  : A probability distribution is a description of how likely a random variable or set of random variables is to take on each of its possible states. probability distribution over discrete variables may be described using a &lt;strong&gt;probability mass function (PMF)&lt;/strong&gt; denoted by P(&lt;em&gt;x&lt;/em&gt;). When working with continuous random variables, we describe probability distributions using a &lt;strong&gt;probability density function (PDF)&lt;/strong&gt; denoted by &lt;em&gt;p(x)&lt;/em&gt;. A probability density function &lt;em&gt;p(x)&lt;/em&gt; does not give the probability of a speciﬁc state directly; instead the probability of landing inside an inﬁnitesimal region with volume δx is given by &lt;em&gt;p(x)&lt;/em&gt;δx.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Conditional Probability&lt;/strong&gt;  : In many cases, we are interested in the probability of some event, given that some other event has happened. This is called a conditional probability. We denote the conditional probability that y = &lt;em&gt;y&lt;/em&gt; given x = &lt;em&gt;x&lt;/em&gt; as P(y=&lt;em&gt;y&lt;/em&gt; | x=&lt;em&gt;x&lt;/em&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kQhppBP6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/443/1%2Af4LedO-X3k4cmlSeAv9_pQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kQhppBP6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/443/1%2Af4LedO-X3k4cmlSeAv9_pQ.png" alt=""&gt;&lt;/a&gt;The conditional probability is only deﬁned when P(x=x) &amp;gt;0&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The Chain Rule of Conditional Probabilities :&lt;/strong&gt; Any joint probability distribution over many random variables may be decomposed into conditional distributions over only one variable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YW_YuIVb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/650/1%2Aj9BZZVw55hnb2jI0_aKM3A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YW_YuIVb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/650/1%2Aj9BZZVw55hnb2jI0_aKM3A.png" alt=""&gt;&lt;/a&gt;Chain rule or product rule of probability&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Expectation&lt;/strong&gt;  : The expectation, or expected value, of some function &lt;em&gt;f(x)&lt;/em&gt; with respect to a probability distribution P(&lt;em&gt;x&lt;/em&gt;) is the average, or mean value, that &lt;em&gt;f&lt;/em&gt; takes on when &lt;em&gt;x&lt;/em&gt; is drawn from P.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sdmYab-U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/335/1%2AoSXW9vM5TjP5ihdhGqCfow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sdmYab-U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/335/1%2AoSXW9vM5TjP5ihdhGqCfow.png" alt=""&gt;&lt;/a&gt;For discrete variables this can be computed with a summation&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Variance :&lt;/strong&gt; The variance gives a measure of how much the values of a function of a random variable x vary as we sample diﬀerent values of &lt;em&gt;x&lt;/em&gt; from its probability distribution.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--imyGkViA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/418/1%2A0AQxWEY6sE5H09wtRiiJaw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--imyGkViA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/418/1%2A0AQxWEY6sE5H09wtRiiJaw.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The square root of the variance is known as the &lt;strong&gt;standard deviation&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Covariance&lt;/strong&gt;  : The covariance gives some sense of how much two values are linearly related to each other, as well as the scale of these variables:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QnG8nRkW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/648/1%2A9bqZmpDeghnAE_8-Gt6fGg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QnG8nRkW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/648/1%2A9bqZmpDeghnAE_8-Gt6fGg.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;High absolute values of the &lt;strong&gt;covariance&lt;/strong&gt; means that the values change very much and are both far from their respective means at the same time. If the sign of the &lt;strong&gt;covariance&lt;/strong&gt; is positive, then both variables tend to take on relatively high values simultaneously. If the sign of the &lt;strong&gt;covariance&lt;/strong&gt; is negative, then one variable tends to take on a relatively high value at the times that the other takes on a relatively low value and vice versa.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bayes’ Rule&lt;/strong&gt;  : Bayes’ theorem is a formula that describes how to update the probabilities of hypotheses when given evidence. It follows simply from the axioms of conditional probability, but can be used to powerfully reason about a wide range of problems involving belief updates. We often ﬁnd ourselves in a situation where we know P(y | x) and need to know P(x | y). Fortunately, if we also know P(x), we can compute the desired quantity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ufQZ5JZ6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/292/1%2AHBBtRBuXKvtQ6LGm7bRLMw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ufQZ5JZ6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/292/1%2AHBBtRBuXKvtQ6LGm7bRLMw.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Common Probability Distributions:-
&lt;/h3&gt;

&lt;p&gt;Some of the common probability distributions used in machine learning are as follows&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bernoulli Distribution&lt;/strong&gt;  : It is a distribution over a single binary random variable. It is controlled by a single parameter φ ∈ [0,1], which gives the probability of the random variable being equal to 1.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z8-rgZ56--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/305/1%2Ao_yH8xdu93G68_SAbnV8PQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z8-rgZ56--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/305/1%2Ao_yH8xdu93G68_SAbnV8PQ.png" alt=""&gt;&lt;/a&gt;Properties of Bernoulli Distribution&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Multinoulli Distribution&lt;/strong&gt;  : The multinoulli, or categorical,distribution is a distribution over a single discrete variable with &lt;em&gt;k&lt;/em&gt; diﬀerent states, where &lt;em&gt;k&lt;/em&gt; is ﬁnite. Multinoulli distributions are often used to refer to distributions over categories of objects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gaussian Distribution&lt;/strong&gt;  : The most commonly used distribution over real numbers is the normal distribution, also known as the Gaussian distribution.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BjphSg9c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/521/1%2AmPhKrBsFbbH9L8kHpSNRQQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BjphSg9c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/521/1%2AmPhKrBsFbbH9L8kHpSNRQQ.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The two parameters &lt;em&gt;µ&lt;/em&gt; ∈ R and &lt;em&gt;σ&lt;/em&gt; ∈ (0, ∞) control the normal distribution. The parameter &lt;em&gt;µ&lt;/em&gt; gives the coordinate of the central peak. This is also the &lt;strong&gt;mean&lt;/strong&gt; of the distribution : E[x] =&lt;em&gt;µ&lt;/em&gt;. The &lt;strong&gt;standard deviation&lt;/strong&gt; of the distribution is given by &lt;em&gt;σ&lt;/em&gt;, and the variance by &lt;em&gt;σ&lt;/em&gt;².&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mFHW6Hwz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/650/1%2AHRj-NCJWQyfZTGa_835ylg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mFHW6Hwz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/650/1%2AHRj-NCJWQyfZTGa_835ylg.png" alt=""&gt;&lt;/a&gt;Plot of the normal distribution density function&lt;/p&gt;

&lt;p&gt;Khan Academy has got a very good course for statistics and probability.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.khanacademy.org/math/statistics-probability"&gt;Statistics and Probability | Khan Academy&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will wrap here. Hope this post helps you in revising some concepts which you learned in high school. 😄 Thank You for reading!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--N1dv4LsS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/375/1%2ADnDyYN3E9t50nn4Iu30bZw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--N1dv4LsS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/375/1%2ADnDyYN3E9t50nn4Iu30bZw.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/Rohitpatil5"&gt;You can find me on Twitter @Rohitpatil5&lt;/a&gt;, or connect with me on &lt;a href="https://www.linkedin.com/in/rohitrpatil/"&gt;LinkedIn.&lt;/a&gt;&lt;/p&gt;




</description>
      <category>deeplearning</category>
      <category>mathematics</category>
      <category>machinelearning</category>
      <category>linearalgebra</category>
    </item>
    <item>
      <title>Indian Government says BIG NO to Self Driving Cars</title>
      <dc:creator>Rohit  Patil</dc:creator>
      <pubDate>Tue, 25 Jul 2017 12:21:03 +0000</pubDate>
      <link>https://dev.to/rohitpatil5/indian-government-says-big-no-to-self-driving-cars-42a</link>
      <guid>https://dev.to/rohitpatil5/indian-government-says-big-no-to-self-driving-cars-42a</guid>
      <description>&lt;p&gt;On 25th July 2017 Nitin Gadkari, Union Minister for Roads and Transport said &lt;strong&gt;India will not allow driver-less cars to ply on its roads&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The reason being that focus of the government is to create more jobs to arrest unemployment.His exact words were “How can we allow such vehicles when we already have huge number of unemployed people?” Gadkari also said there is already annual shortage of about 22,000 trained drivers in India.&lt;/p&gt;

&lt;p&gt;These words come from the same government which could not stop selling of BS-III Vehicles (which was for saving environment) and at last Supreme Court had to intervene to settle the issue once and for all.&lt;/p&gt;

&lt;p&gt;This is where we are wrong. I know India will be the last country in the world where self driving car will go live on roads but still this is not a cogent reason.&lt;/p&gt;

&lt;p&gt;This kind of thinking is not new in India. In the whole world computers were quickly adapted, but in India, they faced opposition and the reason was same (“Unemployment”) and today we see that because of computers many jobs were created.&lt;/p&gt;

&lt;p&gt;I don’t know what happens to companies who are developing SDC’s and need to test on roads.&lt;/p&gt;




</description>
      <category>india</category>
      <category>indiangovernment</category>
      <category>selfdrivingcars</category>
    </item>
  </channel>
</rss>
