<?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 Roopa CM on Medium]]></title>
        <description><![CDATA[Stories by Roopa CM on Medium]]></description>
        <link>https://medium.com/@roopa.usa.cm?source=rss-b024cd242e38------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Roopa CM on Medium</title>
            <link>https://medium.com/@roopa.usa.cm?source=rss-b024cd242e38------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 20:53:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@roopa.usa.cm/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[*args and **kwargs in Python]]></title>
            <link>https://medium.com/@roopa.usa.cm/args-and-kwargs-in-python-8e623464ae4a?source=rss-b024cd242e38------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e623464ae4a</guid>
            <dc:creator><![CDATA[Roopa CM]]></dc:creator>
            <pubDate>Mon, 17 Jun 2024 02:38:26 GMT</pubDate>
            <atom:updated>2024-06-17T02:38:26.262Z</atom:updated>
            <content:encoded><![CDATA[<p>In Python, *args and **kwargs are used in function definitions to allow for variable numbers of arguments. Here&#39;s a detailed explanation of each and how they can be used effectively:</p><h3>*args:</h3><p>*args allows you to pass a variable number of non-keyword arguments to a function. Inside the function, args is treated as a tuple of the arguments passed.</p><h4>Example of *args:</h4><pre>def func_with_args(*args):<br>    for arg in args:<br>        print(arg)<br><br>func_with_args(1, 2, 3, 4)</pre><p><strong>Output:</strong></p><pre>1<br>2<br>3<br>4</pre><h3>**kwargs</h3><p>**kwargs allows you to pass a variable number of keyword arguments to a function. Inside the function, kwargs is treated as a dictionary where the keys are the argument names and the values are the argument values.</p><h4>Example of **kwargs:</h4><pre>def func_with_kwargs(**kwargs):<br>    for key, value in kwargs.items():<br>        print(f&quot;{key} = {value}&quot;)<br><br>func_with_kwargs(name=&quot;Alice&quot;, age=30, city=&quot;New York&quot;)</pre><p><strong>Output:</strong></p><pre>name = Alice<br>age = 30<br>city = New York</pre><h3>Combining *args and **kwargs :</h3><p>You can use both *args and **kwargs in the same function to accept any number of positional and keyword arguments.</p><h4>Example of combining *args and **kwargs:</h4><pre>def func_with_both(*args, **kwargs):<br>    print(&quot;Args:&quot;, args)<br>    print(&quot;Kwargs:&quot;, kwargs)<br><br>func_with_both(1, 2, 3, name=&quot;Alice&quot;, age=30)</pre><p><strong>Output:</strong></p><pre>Args: (1, 2, 3)<br>Kwargs: {&#39;name&#39;: &#39;Alice&#39;, &#39;age&#39;: 30}</pre><h3>Using *args and **kwargs in Function Calls</h3><p>You can also use *args and **kwargs to unpack arguments when calling a function.</p><h4>Example of unpacking with *args and **kwargs:</h4><pre>def greet(name, age, city):<br>    print(f&quot;Hello, my name is {name}, I&#39;m {age} years old and I live in {city}.&quot;)<br><br><br>args = (&quot;Alice&quot;, 30, &quot;New York&quot;)<br>kwargs = {&quot;name&quot;: &quot;Bob&quot;, &quot;age&quot;: 25, &quot;city&quot;: &quot;Los Angeles&quot;}<br>greet(*args)<br>greet(**kwargs)</pre><p><strong>Output:</strong></p><pre>Hello, my name is Alice, I&#39;m 30 years old and I live in New York.<br>Hello, my name is Bob, I&#39;m 25 years old and I live in Los Angeles.</pre><h3>Practical Example</h3><p>Here’s a practical example of a function that uses both *args and **kwargs to process variable numbers of positional and keyword arguments.</p><pre>def process_order(*items, **customer_details):<br>    print(&quot;Order Items:&quot;)<br>    for item in items:<br>        print(f&quot; - {item}&quot;)<br>    print(&quot;\nCustomer Details:&quot;)<br>    for key, value in customer_details.items():<br>        print(f&quot;{key}: {value}&quot;)<br><br>process_order(&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;, name=&quot;Alice&quot;, address=&quot;123 Main St&quot;, phone=&quot;555-1234&quot;)</pre><p><strong>Output:</strong></p><pre>Order Items:<br> - apple<br> - banana<br> - cherry<br><br>Customer Details:<br>name: Alice<br>address: 123 Main St<br>phone: 555-1234</pre><h3>Summary</h3><ul><li>*args is used to pass a variable number of non-keyword arguments to a function.</li><li>**kwargs is used to pass a variable number of keyword arguments to a function.</li><li>They can be combined in function definitions to handle both positional and keyword arguments flexibly.</li><li>They can also be used to unpack arguments when calling functions.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e623464ae4a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Passed by Reference in Python]]></title>
            <link>https://medium.com/@roopa.usa.cm/passed-by-reference-in-python-40a9372ab2eb?source=rss-b024cd242e38------2</link>
            <guid isPermaLink="false">https://medium.com/p/40a9372ab2eb</guid>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[Roopa CM]]></dc:creator>
            <pubDate>Mon, 17 Jun 2024 02:30:50 GMT</pubDate>
            <atom:updated>2024-06-17T02:30:50.927Z</atom:updated>
            <content:encoded><![CDATA[<p>In Python, understanding whether variables are passed by reference or by value can be a bit nuanced. Here’s a detailed explanation to clarify the concepts:</p><h3>Parameter Passing in Python</h3><p>Python uses a mechanism known as “pass-by-object-reference” or “pass-by-assignment.” This means that the function receives a reference to the same object in memory, not a copy of the object. The behavior can seem like a mix of pass-by-value and pass-by-reference, depending on the type of object involved.</p><h3>Mutable vs. Immutable Objects</h3><p>To understand the behavior, it’s crucial to differentiate between mutable and immutable objects:</p><ul><li><strong>Immutable Objects:</strong> Integers, floats, strings, and tuples.</li><li><strong>Mutable Objects:</strong> Lists, dictionaries, sets, and most other objects.</li></ul><h3>Immutable Objects</h3><p>When you pass an immutable object to a function, any modification to the parameter within the function does not affect the original object. This is because a new object is created if you try to change its value.</p><pre>def modify_immutable(x):<br>    x = 10  # This creates a new integer object inside the function<br>    print(&quot;Inside function:&quot;, x)<br><br>a = 5<br>modify_immutable(a)<br>print(&quot;Outside function:&quot;, a)</pre><p><strong>Output:</strong></p><pre>Inside function: 10<br>Outside function: 5</pre><h3>Mutable Objects</h3><p>When you pass a mutable object to a function, changes made to the object within the function do affect the original object because the reference to the same object is passed.</p><pre>def modify_mutable(lst):<br>    lst.append(4)  # This modifies the original list<br>    print(&quot;Inside function:&quot;, lst)<br><br>my_list = [1, 2, 3]<br>modify_mutable(my_list)<br>print(&quot;Outside function:&quot;, my_list)</pre><p><strong>Output:</strong></p><pre>Inside function: [1, 2, 3, 4]<br>Outside function: [1, 2, 3, 4]</pre><h3>Practical Example</h3><p>Consider the following example where both mutable and immutable objects are used:</p><pre>def modify_objects(num, lst):<br>    num += 1<br>    lst.append(100)<br>    print(&quot;Inside function - num:&quot;, num)<br>    print(&quot;Inside function - lst:&quot;, lst)<br><br>n = 10<br>my_list = [1, 2, 3]<br>modify_objects(n, my_list)<br>print(&quot;Outside function - n:&quot;, n)<br>print(&quot;Outside function - my_list:&quot;, my_list)</pre><p><strong>Output:</strong></p><pre>Inside function - num: 11<br>Inside function - lst: [1, 2, 3, 100]<br>Outside function - n: 10<br>Outside function - my_list: [1, 2, 3, 100]</pre><h3>Key Points</h3><ol><li><strong>Immutable objects:</strong> The function works with a local copy, and changes do not affect the original object.</li><li><strong>Mutable objects:</strong> The function works with a reference to the same object, and changes affect the original object.</li></ol><p>Understanding these principles helps in predicting and controlling the behavior of your Python code, especially when dealing with functions and different types of data structures.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40a9372ab2eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Activation Functions in Artificial Neural Network]]></title>
            <link>https://medium.com/@roopa.usa.cm/activation-functions-in-artificial-neural-network-454897f859ba?source=rss-b024cd242e38------2</link>
            <guid isPermaLink="false">https://medium.com/p/454897f859ba</guid>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[hidden-layers]]></category>
            <category><![CDATA[activation-functions]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[backpropagation]]></category>
            <dc:creator><![CDATA[Roopa CM]]></dc:creator>
            <pubDate>Tue, 13 Sep 2022 23:45:59 GMT</pubDate>
            <atom:updated>2022-09-13T23:45:59.819Z</atom:updated>
            <content:encoded><![CDATA[<p>An artificial neural network is an interconnected group of nodes, inspired by a simplification of <a href="https://en.wikipedia.org/wiki/Neuron">neurons</a> in a brain. Here, each circular node represents an <a href="https://en.wikipedia.org/wiki/Artificial_neuron">artificial neuron</a> and an arrow represents a connection from the output of one artificial neuron to the input of another.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*knTHwSN-cl-Eus-zupz-Ig.png" /></figure><p>As shown in the above figure, Inputs are fed into the nodes in the input layer. Inputs(Xi) are then multiplied with their weights(Wi) and add the bias gives the output(y=(Xi*Wi)+b) of the neuron. We apply our activation function on <strong>Y</strong> then it is transfer to the next layer.</p><p><em>y = (w1 x1 + w2 x2 + … + wn xn + b)</em></p><p>These outputs of each layer are fed into the next subsequent layer for multilayered networks until the final output is obtained, but they are linear by default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*QQJhd96PlxAuIF6CRqwbuA.png" /><figcaption>Example for multi-layered network</figcaption></figure><p>Since the outputs are linear in nature, the nonlinear activation functions are required to convert these linear inputs to non-linear outputs. These transfer functions, applied to the outputs of the linear models to produce the transformed non-linear outputs are ready for further processing. The non-linear output after the application of the activation function is given by</p><p><em>y = α (w1 x1 + w2 x2 + … + wn xn + b)</em></p><p>where <em>α</em> is the activation function.</p><p>The purpose of the activation function is to <strong>introduce non-linearity</strong> into the output .</p><p>Finally, the output from the activation function moves to the next hidden layer and the same process is repeated. This forward movement of information is known as the <strong><em>forward propagation</em></strong>.</p><p>What if the output generated is far away from the actual value? Using the output from the forward propagation, error is calculated. Based on this error value, the weights and biases of the neurons are updated. This process is known as <strong><em>back-propagation</em></strong>.</p><h3><strong>Three Types of Activation Functions:</strong></h3><h3>Binary Step Function:</h3><p>Binary step function depends on a threshold value that decides whether a neuron should be activated or not.</p><p>The input fed to the activation function is compared to a certain threshold; if the input is greater than it, then the neuron is activated, else it is deactivated, meaning that its output is not passed on to the next hidden layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*xgQkXfATSgIQS-eqB0giYg.png" /><figcaption>Binary Step function</figcaption></figure><p>Mathematically,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*u8knLzm_y0stUtq1ux-GPA.png" /></figure><p>The binary step function can be used as an activation function while creating a binary classifier.</p><p>As you can imagine, this function will not be useful when there are multiple classes in the target variable. That is one of the limitations of binary step function.</p><p>Moreover, the gradient of the step function is zero which causes a hindrance in the back propagation process. That is, if you calculate the derivative of f(x) with respect to x, it comes out to be 0.</p><p>Gradients are calculated to update the weights and biases during the backprop process. Since the gradient of the function is zero, the weights and biases don’t update.</p><h3>Linear Activation Function</h3><p>The linear activation function, also known as “no activation,” or “identity function” , is where the activation is proportional to the input.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*i6d2IrSo--qHjl1uL8-0Kw.png" /><figcaption>Linear Activation Function</figcaption></figure><p>Mathematically,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/251/1*AikXPFUJWN8VWMbpUZpjsQ.png" /></figure><p>We saw the problem with the step function, the gradient of the function became zero. This is because there is no component of x in the binary step function. Instead of a binary function, we can use a linear function.</p><p>Although the gradient here does not become zero, but it is a constant which does not depend upon the input value x at all. This implies that the weights and biases will be updated during the backpropagation process but the updating factor would be the same.</p><p>In this scenario, the neural network will not really improve the error since the gradient is the same for every iteration. The network will not be able to train well and capture the complex patterns from the data.</p><p>All layers of the neural network will collapse into one if a linear activation function is used. No matter the number of layers in the neural network, the last layer will still be a linear function of the first layer. So, essentially, a linear activation function turns the neural network into just one layer.</p><h3>Non-Linear Activation Functions</h3><p>The linear activation function shown above is simply a linear regression model.</p><p>Because of its limited power, this does not allow the model to create complex mappings between the network’s inputs and outputs.</p><p>Non-linear activation functions solve the following limitations of linear activation functions:</p><ul><li>They allow backpropagation because now the derivative function would be related to the input, and it’s possible to go back and understand which weights in the input neurons can provide a better prediction.</li><li>They allow the stacking of multiple layers of neurons as the output would now be a non-linear combination of input passed through multiple layers. Any output can be represented as a functional computation in a neural network.</li></ul><p>Let’s have a look at some of the different non-linear neural networks activation functions and their characteristics.</p><h4>Sigmoid / Logistic Activation Function</h4><p>This function takes any real value as input and outputs values in the range of 0 to 1.</p><p>The larger the input (more positive), the closer the output value will be to 1.0, whereas the smaller the input (more negative), the closer the output will be to 0.0, as shown below.</p><p>The sigmoid activation function translates the input ranged in (-∞,∞) to the range in (0,1).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/1*2t9X6FDQBM33Hx1Oc06qsg.png" /><figcaption>Sigmoid Activation Function</figcaption></figure><p>Mathematically,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/1*hbD1QGMPDYBsqHRhncx2bQ.png" /></figure><p>A noteworthy point here is that unlike the binary step and linear functions, sigmoid is a non-linear function. This essentially means, when I have multiple neurons having sigmoid function as their activation function, the output is non linear as well.</p><p>Sigmoid/logistic activation function is one of the most widely used functions:</p><ul><li>It is commonly used for models where we have to predict the probability as an output. Since probability of anything exists only between the range of 0 and 1, sigmoid is the right choice because of its range.</li><li>The function is differentiable and provides a smooth gradient, i.e., preventing jumps in output values. This is represented by an S-shape of the sigmoid activation function.</li></ul><p>The derivative of the function is f’(x) = sigmoid(x)*(1-sigmoid(x)).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/1*56wibR04GCgwf_FaftHAtQ.png" /><figcaption>Derivative of Sigmoid Function</figcaption></figure><p>As we can see from the above Figure, the gradient values are only significant for range -3 to 3, and the graph gets much flatter in other regions.</p><p>It implies that for values greater than 3 or less than -3, the function will have very small gradients. As the gradient value approaches zero, the network ceases to learn and suffers from the <em>Vanishing gradient</em> problem.</p><p>Additionally, the sigmoid function is not symmetric around zero. So output of all the neurons will be of the same sign. This makes the training of the neural network more difficult and unstable. This can be addressed by scaling the sigmoid function which is exactly what happens in the tanh activation function.</p><h4>Tanh Function (Hyperbolic Tangent)</h4><p>Tanh function is very similar to the sigmoid/logistic activation function, and even has the same S-shape with the difference in output range of -1 to 1. In Tanh, the larger the input (more positive), the closer the output value will be to 1.0, whereas the smaller the input (more negative), the closer the output will be to -1.0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/305/1*pGmgZa8VpHpJi-I618rlzA.png" /><figcaption>Tanh Activation Function</figcaption></figure><p>Mathematically,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*KuNM05OQaN-phPi-Avxj8A.png" /></figure><p>The output of the tanh activation function is Zero centered; hence we can easily map the output values as strongly negative, neutral, or strongly positive.</p><p>Usually used in hidden layers of a neural network as its values lie between -1 to 1. Therefore, the mean for the hidden layer comes out to be 0 or very close to it. It helps in centering the data and makes learning for the next layer much easier.</p><p>Have a look at the gradient of the tanh activation function to understand its limitations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*XrnLvs3xEDLMpyF53Y5cSg.png" /><figcaption>Gradient of Tanh Activation Function</figcaption></figure><p>The gradient of the tanh function is steeper as compared to the sigmoid function. It also faces the problem of vanishing gradients similar to the sigmoid activation function.</p><p>How will we decide which activation function to choose? Usually tanh is preferred over the sigmoid function since it is zero centered and the gradients are not restricted to move in a certain direction.</p><h4>ReLU Function (Rectified Linear Unit)</h4><p>Although it gives an impression of a linear function, ReLU has a derivative function and allows for backpropagation while simultaneously making it computationally efficient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*hj0L4TMsJnRzoxcyWfti0Q.png" /><figcaption>ReLU Activation Function</figcaption></figure><p>Mathematically,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/364/1*VtfNhvQtD0msP8sFo0BqJw.png" /></figure><p>The main advantage of using the ReLU function over other activation functions is that it does not activate all the neurons at the same time.</p><p>This means that the neurons will only be deactivated if the output of the linear transformation is less than 0.</p><p>Since only a certain number of neurons are activated, the ReLU function is far more computationally efficient when compared to the sigmoid and tanh function.</p><p>The limitations faced by this function is the <strong>Dying ReLU problem.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/348/1*zOET45MEQshGBf18tk3qtQ.png" /><figcaption>Gradient of ReLU Activation Function</figcaption></figure><p>The negative side of the graph makes the gradient value zero. Due to this reason, during the backpropagation process, the weights and biases for some neurons are not updated. This can create dead neurons which never get activated.</p><p>All the negative input values become zero immediately, which decreases the model’s ability to fit or train from the data properly. This is taken care of by the ‘Leaky’ ReLU function.</p><h4>Leaky ReLU Function</h4><p>Leaky ReLU function is nothing but an improved version of the ReLU function. As we saw that for the ReLU function, the gradient is 0 for x&lt;0, which would deactivate the neurons in that region.</p><p>Leaky ReLU is defined to address this problem. Instead of defining the Relu function as 0 for negative values of x, we define it as an extremely small linear component of x.</p><p>Here is the mathematical expression-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*pKrkVErbCF_BjCTP2xdhkA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/347/1*SxrjzmOCGtBzXaxYyXt8fQ.png" /><figcaption>Leaky ReLU Activation Function</figcaption></figure><p>The advantages of Leaky ReLU are same as that of ReLU, in addition to the fact that it does enable backpropagation, even for negative input values.</p><p>By making this minor modification for negative input values, the gradient of the left side of the graph comes out to be a non-zero value. Therefore, we would no longer encounter dead neurons in that region.</p><p>Here is the derivative of the Leaky ReLU function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/1*p4ru4vqmMGQ_8G3SUXxtyQ.png" /><figcaption>Derivative of Leaky ReLU Activation function</figcaption></figure><p>The limitations that this function faces include:</p><ul><li>The predictions may not be consistent for negative input values.</li><li>The gradient for negative values is a small value that makes the learning of model parameters time-consuming.</li></ul><p>Apart from Leaky ReLU, there are a few other variants of ReLU, the two most popular are — Parameterised ReLU function and Exponential ReLU.</p><h4>Parametric ReLU Function</h4><p>Parametric ReLU is another variant of ReLU that aims to solve the problem of gradient’s becoming zero for the left half of the axis.</p><p>The parameterised ReLU, as the name suggests, introduces a new parameter as a slope of the negative part of the function as an argument <em>a</em>. By performing backpropagation, the most appropriate value of <em>a</em> is learnt.</p><p>Here’s how the ReLU function is modified to incorporate the slope parameter-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*5kaMIwIZ7dY8YJ0nRgunAw.png" /><figcaption>Parametric ReLU Activation Function</figcaption></figure><p>Mathematically,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*gO7Um7Y2r0XFwZIwaufOgQ.png" /></figure><p>When the value of a is fixed to 0.01, the function acts as a Leaky ReLU function. However, in case of a parameterised ReLU function, ‘<strong>a</strong>‘ is also a trainable parameter. The network also learns the value of ‘<strong>a</strong>‘ for faster and more optimum convergence.</p><p>The derivative of the function would be same as the Leaky ReLu function, except the value 0.01 will be replcaed with the value of a.</p><p>The parameterized ReLU function is used when the leaky ReLU function still fails to solve the problem of dead neurons and the relevant information is not successfully passed to the next layer.</p><p>This function’s limitation is that it may perform differently for different problems depending upon the value of slope parameter <em>a.</em></p><h4>Exponential Linear Units (ELUs) Function</h4><p>Exponential Linear Unit or ELU is also a variant of Rectified Linear Unit (ReLU) that modifies the slope of the negative part of the function. Unlike the leaky ReLU and parametric ReLU functions, instead of a straight line, ELU uses a log curve for defining the negative values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/287/1*7w2Hd7leRy0ZmVS4OAi6Dw.png" /><figcaption>ELU Activation Function</figcaption></figure><p>Mathematically,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*jrMJQAl1hwyek77t4C34nw.png" /></figure><p>ELU is a strong alternative for ReLU because of the following advantages:</p><ul><li>ELU becomes smooth slowly until its output equal to -α whereas RELU sharply smoothes.</li><li>Avoids dead ReLU problem by introducing log curve for negative values of input. It helps the network nudge weights and biases in the right direction.</li></ul><p>The derivative of the ELU function for values of x greater than 0 is 1, like all the ReLU variants. But for values of x&lt;0, the derivative would be a.e^x .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*0W3x3GQXBP0cI9hhpprcsw.png" /></figure><p>The limitations of the ELU function are as follow:</p><ul><li>It increases the computational time because of the exponential operation included</li><li>No learning of the ‘a’ value takes place</li><li>Exploding gradient problem</li></ul><h4>Softmax Function</h4><p>Softmax function is often described as a combination of multiple sigmoids. We know that sigmoid returns values between 0 and 1, which can be treated as probabilities of a data point belonging to a particular class. Thus sigmoid is widely used for binary classification problems.</p><p>The softmax function can be used for multiclass classification problems. This function returns the probability for a datapoint belonging to each individual class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/304/1*4dQZ09VdCj_0HhAbhhgthQ.png" /><figcaption>Softmax Activation Function</figcaption></figure><p>Mathematically,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/292/1*mSy5wFzjM-bL_L0H4GKvjA.png" /></figure><p>While building a network for a multiclass problem, the output layer would have as many neurons as the number of classes in the target. For instance if you have three classes, there would be three neurons in the output layer. Suppose you got the output from the neurons as [1.2 , 0.9 , 0.75].</p><p>Applying the softmax function over these values, you will get the following result — [0.42 , 0.31, 0.27]. These represent the probability for the data point belonging to each class. Note that the sum of all the values is 1.</p><p>You can see now how softmax activation function make things easy for multi-class classification problems.</p><h4>Swish</h4><p>It is a self-gated activation function developed by researchers at Google.</p><p>Swish is as computationally efficient as ReLU and shows better performance than ReLU on deeper models. The values for swish ranges from negative infinity to infinity.</p><p>As you can see, the curve of the function is smooth and the function is differentiable at all points. This is helpful during the model optimization process and is considered to be one of the reasons that swish outperforms ReLU.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*F9BirsyC8SG1uGvzPhzKDg.png" /><figcaption>Swish Activation Function</figcaption></figure><p>Mathematically,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/371/1*z_gARz-AhF4X7v4uagdTyQ.png" /></figure><p>Here are a few advantages of the Swish activation function over ReLU:</p><ul><li>Swish is a smooth function that means that it does not abruptly change direction like ReLU does near x = 0. Rather, it smoothly bends from 0 towards values &lt; 0 and then upwards again.</li><li>Small negative values were zeroed out in ReLU activation function. However, those negative values may still be relevant for capturing patterns underlying the data. Large negative values are zeroed out for reasons of sparsity making it a win-win situation.</li><li>The swish function being non-monotonous enhances the expression of input data and weight to be learnt.</li></ul><h3>Is Deep neural networks hard to train?</h3><p>There are two challenges you might encounter when training your deep neural networks.</p><p>Let’s discuss them in more detail.</p><h4>Vanishing Gradients</h4><p>Like the sigmoid function, certain activation functions squish an ample input space into a small output space between 0 and 1.</p><p>Therefore, a large change in the input of the sigmoid function will cause a small change in the output. Hence, the derivative becomes small. For shallow networks with only a few layers that use these activations, this isn’t a big problem.</p><p>However, when more layers are used, it can cause the gradient to be too small for training to work effectively.</p><h4>Exploding Gradients</h4><p>Exploding gradients are problems where significant error gradients accumulate and result in very large updates to neural network model weights during training.</p><p>An unstable network can result when there are exploding gradients, and the learning cannot be completed.</p><p>The values of the weights can also become so large as to overflow and result in something called NaN values.</p><h3>Choosing the right Activation Function</h3><p>You need to match your activation function for your output layer based on the type of prediction problem that you are solving — specifically, the type of predicted variable.</p><p>Here’s what you should keep in mind.</p><p>As a rule of thumb, you can begin with using the ReLU activation function and then move over to other activation functions if ReLU doesn’t provide optimum results.</p><p>And here are a few other guidelines to help you out.</p><ol><li>ReLU activation function should only be used in the hidden layers.</li><li>Sigmoid/Logistic and Tanh functions should not be used in hidden layers as they make the model more susceptible to problems during training (due to vanishing gradients).</li><li>Swish function is used in neural networks having a depth greater than 40 layers.</li></ol><p>Finally, a few rules for choosing the activation function for your output layer based on the type of prediction problem that you are solving:</p><ol><li>Regression — Linear Activation Function</li><li>Binary Classification — Sigmoid/Logistic Activation Function</li><li>Multiclass Classification — Softmax</li><li>Multilabel Classification — Sigmoid</li></ol><p>The activation function used in hidden layers is typically chosen based on the type of neural network architecture.</p><ol><li>Convolutional Neural Network (CNN): ReLU activation function.</li><li>Recurrent Neural Network: Tanh and/or Sigmoid activation function.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=454897f859ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Time Complexity of Python Data Structures]]></title>
            <link>https://medium.com/@roopa.usa.cm/time-complexity-of-python-data-structures-d799c451d1ce?source=rss-b024cd242e38------2</link>
            <guid isPermaLink="false">https://medium.com/p/d799c451d1ce</guid>
            <category><![CDATA[time-complexity]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Roopa CM]]></dc:creator>
            <pubDate>Thu, 09 Jun 2022 20:51:00 GMT</pubDate>
            <atom:updated>2022-06-09T20:51:00.395Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Time complexity</strong> estimates how an algorithm performs regardless of the kind of machine it runs on. You can get the time complexity by “counting” the number of operations performed by your code. This time complexity is defined as a function of the input size n using Big-O notation. n indicates the input size, while O is the worst-case scenario growth rate function.</p><p>We use the Big-O notation to classify algorithms based on their running time or space (memory used) as the input grows. The O function is the growth rate in function of the input size n.</p><p>Generally used few Big O Notions are given below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*kC9z-sjCoGfMAJZJX5R8zA.png" /></figure><p>Lets see few examples to understand this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nW_tjE0FzjB-gtrTPYlg3g.png" /></figure><p>In the above code whatever may be the value of c, the print statement executes only once which means constant. So, time complexity is <strong>constant: O(1)</strong> i.e. every time constant amount of time is required to execute code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bbzH_UrazXoWdyPD7yiGhA.png" /></figure><p>whereas in the above code, the number of times the print statement executes depends on the n value, means linearly dependent on input value n. So, time complexity is <strong>linear: O(n)</strong> i.e. every time, linear amount of time is required to execute code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eW2jWIajMt3wG_Frwb3AYg.png" /></figure><p>Lets look at one more example here. In the above code there are nested for loops. Here the print statement is executed n2 times. As the n value changes the number of time the print statement executed will be changed quadratically. So, time complexity is <strong>Quadratic: O(n^2).</strong></p><h3>Time Complexity for Python Data Structures</h3><p>Lets check the Time complexity for Python Operations. Python built-in data structures like list,set, dict provide a large number of operations making it easier to write concise code but not being aware of their complexity can result in unexpected slow behavior of your python code.</p><p>Generally, ’n’ is the number of elements currently in the container. ‘k’ is either the value of a parameter or the number of elements in the parameter.</p><h3><strong>List:</strong></h3><p>Internally, a list is represented as an array; the largest costs come from growing beyond the current allocation size (because everything must move), or from inserting or deleting somewhere near the beginning (because everything after that must move).</p><p>The Average Case assumes parameters generated uniformly at random.</p><p><strong>Amortized analysis</strong> is a method for <a href="https://en.wikipedia.org/wiki/Analysis_of_algorithms">analyzing</a> a given algorithm’s <a href="https://en.wikipedia.org/wiki/Computational_complexity_theory">complexity</a>, or how much of a resource, especially time or memory, it takes to <a href="https://en.wikipedia.org/wiki/Execution_(computing)">execute</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*azheiwhiVbKZvH4ngFMqaA.png" /></figure><p><strong>Note: </strong>Tuples have the same operations (non-mutable) and complexities.</p><h3><strong>Set:</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IDbUWfsvaRKf52kLLEf_2w.png" /></figure><h3><strong>Dict:</strong></h3><p>The Average Case assumes the keys used in parameters are selected uniformly at random from the set of all keys.</p><p>Note that there is a fast-path for dicts that (in practice) only deal with str keys; this doesn’t affect the algorithmic complexity, but it can significantly affect the constant factors: how quickly a typical program finishes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*Tcv-c5kt6S2aS5VUwtQQMA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d799c451d1ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Config Git , GitHub & SSH set up]]></title>
            <link>https://medium.com/@roopa.usa.cm/config-git-github-ssh-set-up-456b5041322f?source=rss-b024cd242e38------2</link>
            <guid isPermaLink="false">https://medium.com/p/456b5041322f</guid>
            <category><![CDATA[cloud-services]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[ssh-keys]]></category>
            <dc:creator><![CDATA[Roopa CM]]></dc:creator>
            <pubDate>Thu, 19 May 2022 05:37:14 GMT</pubDate>
            <atom:updated>2022-05-19T05:37:14.168Z</atom:updated>
            <content:encoded><![CDATA[<h3>Config Git , GitHub &amp; SSH set up</h3><p><strong>Git is a version control tool to track the changes in the source code</strong>. <strong>GitHub</strong> is a web-based centralized cloud service to host our source code (our local Git repositories).</p><p><strong>SSH</strong>, also known as <strong>Secure Shell</strong> or Secure Socket Shell, is a network protocol that gives users, a secure way to access a computer over an unsecured network. <strong>Git uses SSH to establish a secure connection through which it can execute commands</strong>.</p><p><strong>INSTALLATION</strong>:</p><ul><li>Download and install <a href="https://git-scm.com/downloads">git</a>.</li><li>create a <a href="https://github.com/">github</a> account.</li></ul><p>To set up git with your user name and email open a terminal and type: This is required only once when your setting up for the first time.</p><pre>$ git config --global user.name &quot;Your name&quot;<br>$ git config --global user.email &quot;your_email@example.com&quot;</pre><p>To setup ssh on your computer, create public/private keys. Open a terminal and type:</p><pre>$ ssh-keygen -t rsa -C &quot;your_email@example.com&quot;</pre><p>Now copy your public key (the contents of the newly-created id_rsa.pub file) into your clipboard and paste your ssh public key into your Github account settings.</p><ul><li>Go to Github <a href="https://github.com/settings/profile">Account Settings</a></li><li>Click “<a href="https://github.com/settings/ssh">SSH Keys</a>” on the left.</li><li>Click “Add SSH Key” on the right.</li><li>Add a label and paste the public key into the big text box.</li><li>In a terminal, type the following to test it:</li></ul><pre>$ ssh -T git@github.com</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=456b5041322f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Git & GitHub]]></title>
            <link>https://medium.com/@roopa.usa.cm/introduction-to-git-github-fd0a5c09ae83?source=rss-b024cd242e38------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd0a5c09ae83</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[cloud-services]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Roopa CM]]></dc:creator>
            <pubDate>Thu, 19 May 2022 05:33:46 GMT</pubDate>
            <atom:updated>2023-10-05T23:09:07.352Z</atom:updated>
            <content:encoded><![CDATA[<p>Git is a open source version control system that’s responsible for everything GitHub related that happens locally on your computer.</p><p>The general use of Git involves few commands: mainly add, commit, and push, but also status and diff.</p><p>You can work with Git and GitHub using GUI, but here we are discussing using command line. Because at the beginning it is good to deal with command line.</p><h3>add &amp; commit</h3><p>If you made modifications to your project and checked that they work, use git add to indicate that they’re ready.</p><pre>$ git add [file]</pre><p>Then use git commit to add the modifications to the repository.</p><pre>$ git commit -m “[descriptive message]”</pre><p>Note that git add is used to add completely new files as well as to “add” modifications to files that already exist in the repository. The commit message should be short (40 or 60 characters) so it’s easy to read in a list.</p><p>If you want to add all the files or add modifications of all the files instead of adding each file you can also do</p><pre>$ git add .</pre><p>If you want to commit all of the modifications you’ve made, without having to explicitly “add” each file, you can skip the separate add and commit commands and just type</p><pre>$ git commit -a</pre><h3>Push</h3><p>To push committed changes to GitHub, type</p><pre>$ git push [alias] [branch]</pre><p>You don’t need to do this every time. You do it after you’ve completed a set of changes. It will transmit local commits to the remote repository in GitHub.</p><h3>Status</h3><p>You’ve made some changes to a project, to check them. Type</p><pre>$ git status</pre><p>It’ll give you a list of files that have been changed, and also new files that haven’t been formally added(untracked files).</p><h3>Diff</h3><p>To check what changes have you made exactly? Type</p><pre>$ git diff</pre><p>Or to see your changes to a particular file, type</p><pre>$ git diff [file]</pre><p>It’ll show you which lines have been added and which have been deleted.</p><h3><strong>Creating a new Git repository</strong></h3><p>To initialize an existing directory as a Git repository</p><pre>$ git init</pre><h3>A new repo (short form of repository) from scratch</h3><ul><li>Create a directory to contain the project.</li><li>Go into the new directory.</li><li>Type git init.</li></ul><p>which initializes the existing directory as a Git repository</p><ul><li>Type git add to add the files .</li><li>Type git commit.</li></ul><p>The first file to create (and add and commit) is probably a ReadMe file, either as plain text or with Markdown (.md), describing the project.</p><h3>Connect it to GitHub</h3><p>Now you have a local git repository. To host it on GitHub, do the following.</p><ul><li>Go to <a href="https://github.com/">GitHub</a>.</li><li>Log in to your account.</li><li>Click the <a href="https://github.com/new">new repository</a> button in the top-right. You’ll have an option there to initialize the repository with a README file.</li><li>Click the “Create repository” button.</li></ul><p>Now, follow the second set of instructions, “Push an existing repository…”</p><pre>$ git remote add origin git@github.com:username/new_repo<br>$ git push -u origin master</pre><p>Actually, the first line of the instructions will say</p><pre>$ git remote add origin <a href="https://github.com/username/new_repo">https://github.com/username/new_repo</a></pre><p>But I use git@github.com:username/new_repo rather than https://github.com/username/new_repo, as the former is for use with <a href="https://en.wikipedia.org/wiki/Secure_Shell">ssh</a> (if you set up ssh , then you won’t have to type your password every time you push things to GitHub). If you use the later construction, you’ll have to type your GitHub password every time you push to GitHub.</p><h3><strong>To get from existing repo to local machine:</strong></h3><ul><li>Go to the repository on GitHub.</li><li>Click the “CODE” button .</li><li>Copy the SSH link of the repository.</li><li>Open a terminal and type</li></ul><pre>$ git clone [url]</pre><ul><li>where url is link of the repository from a hosted location.</li></ul><p>For example:</p><pre>$ git clone git@github.com:username/repo_name</pre><p>where username is <em>your</em> username.</p><ul><li>Now you will have a local copy of <em>your version</em> of that repository.</li><li>To go into that project directory (the_repo):</li></ul><pre>$ cd repo_name</pre><ul><li>To add connection to the original repository.</li></ul><pre>$ git remote add [alias] [url]</pre><h3>Pull</h3><p>To fetch and merge any commits from the tracking remote branch.</p><p>Go into the directory for the project and type:</p><pre>$ git pull </pre><p>Now push them back to your GitHub repository using.</p><pre>$ git push</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd0a5c09ae83" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>