Posts

Notes on pointer in C

A pointer is a memory address. Assume size of int and char in the compiler as 4 and 1 Byte respectively. & : address of * : Content of (de-referencing operator) int x; //x occupies 4 byte memory int *p; //p is a pointer and address of an integer. It means *p (content of p) will be an integer. p= &x; //now, p is address of x. p is pointer to integer x. p++; //move pointer to next element. As p is the pointer to integer, it's value will increase by 4. int **q; // q is pointer to pointer. (address of address) q=&p; //q is now pointer to pointer to (address of) p. Size of a pointer is fixed for a compiler irrespective of pointer type.  p=(char*)p; //now p is address of char, content of p (*p) will be of size 1 Byte. I recommend to go through this test for checking yourself : https://www.geeksforgeeks.org/c-language-2-gq/pointers-gq/

Simple Interest calculator using HTML and JavaScript

Code: <html>     <head>         <title>Simple interest</title>         <script>             function displynum()             {                 simi.txt4.value=eval("("+simi.txt1.value+"*"+simi.txt2.value+"*"+simi.txt3.value+")"+"/"+"100");             }         </script>     </head>         <body>         Simple Interest Calculator<br><br>         <form name=simi>             Principal amount<br>             <input type=text name=txt1 style="text-align:right"><br><br>             Number of year<br>             <input type=text name=txt2 style="text-align:right"><br><br>             Rate (per year)<br>             <input type=text name=txt3 style="text-align:right"><br><br>             <input type=button name=eqlbtn value="Submit&qu

Simple Calculator using HTML and JavaScript

Code: <html>     <head>         <title>Calculator</title>                 <script type="text/javascript">                         function displynum(n1)             {                 calcform.txt1.value=calcform.txt1.value+n1;             }                         </script>     </head>         <body>         <form name=calcform>             <input type=text name=txt1 style="text-align:right">             <br>             <input type=button name=btn9 value=9 onclick="displynum(btn9.value)">             <input type=button name=btn8 value=8 onclick="displynum(btn8.value)">             <input type=button name=btn7 value=7 onclick="displynum(btn7.value)">             <input type=button name=addbtn value=+ onclick="displynum(addbtn.value)">             <br>             <input type=button name=btn6 value=6 onc

Physical Significance of Convolution

Image
Convolution is an operation that takes input signal, and return output signal based on knowledge about the system’s unit impulse response. For a continuous 1-dimensional system, System response (Output) is convolution of input signal and impulse response of the system. 1-d Convolution is defined like this.. where x(t) is input signal, y(t) is output signal and h(t) is impulse response. See this self elaborating example of convolution for physical significance…. The physical significance can be better understand by 2-d convolution. As we know that an image is nothing but a 2 -dimensional function and can be represented as a matrix. Here, second matrix is impulse response. Generally we don’t see such clear-cut pattern due to overlapping of values. Thanks for reading and your suggestions!  

Convolutional Neural Network

Image
Prequisite :  Basic knowledge of Neural Network Convolutional Neural Network is a supervised deep learning algorithm. It is used for image classification, recommender system and natural language processing. Image classification means categorization of image into particular class like finding cats out of cats and dogs. CNN is inspired by biological structure and process of animal’s virtual cortex. Alike Neural Network (NN), CNN is also made of neurons with trainable weights and biases. A neuron takes weighted sum input from previous layer neurons, and apply an activation function to it. The whole CNN model has a loss function, on training by input-output sets, weights and biases are trained so as to decrease the loss function. The first difference between CNN and NN is that, NN’s input is a vector and CNN’s input is a multi-channeled image (RGB color channels).   CNN consists of input-output layers and in between hidden layers. Input layer is set of pixels of input image, whereas

Save and Restore variable in TensoFlow-Python

Saving and restoring of variable is frequently used in Machine learning applications. Once a model is trained, trained variable should be stored for future usage of model without re-training. I am presenting a simple code of Linear regression using Gradient descent. If you will run this code first time, it will do training and save the variable value. If you are running the code again it will used saved value for testing. import tensorflow as tf import numpy as np import os.path itr=20#number of iteration for training x=np.array([1,2,3,4,5,6]).astype(np.float32) y=np.array([1.8,3,3.98,5,6.1,7.2]).astype(np.float32) xt=np.array([2.5]).astype(np.float32) #for testing m=tf.Variable(2.0) c=tf.Variable(1.0) y_p=m*x+c yt=m*xt+c#output for test loss=tf.reduce_mean(tf.square(y_p-y)) optimizer=tf.train.GradientDescentOptimizer(0.01) train=optimizer.minimize(loss) with tf.Session() as sess:     init_op=tf.global_variables_initializer()     sess.run(init_op)     # Add ops to save and