Skip to main content

Posts

Stochastic gradient descent with multiple variables

 The idea is to understand how u can create a sample for stochastic gradient descent using python , numpy and some basic maths. so what is gradient descent  u might be bored with the term and it is always boring with visualization here i will run through a sample using python and plot that in mat plot lib for visual. matplot lib is another library u can install on the go and it is like a simple x,y graph that we used in our school days.don't worry this is pretty simple. 1.install python - https://www.python.org/downloads/ if you are using windows it will be a exe run that . once installed type in command line   since the function is  y = w1* x1 +w2 * x2 +b we will use the know  mean square error loss function  mae  = (y - y_hat)**2 next step would be to calculate partial derivatives for w1 , w2 , b  with respect to y dy/dw1 = x1 dy/dw2 = x2  dy/db = 1 h = (y - y_hat) ** 2  h = u **2 , u = y - y_hat dh/du = 2u = 2 (y - y_hat) du/dy = 1 by chain rule dh/dy = dh/du * du/dy dh/dy = 2

Tutorial - numpy for changing color of an image at pixel level.

import numpy as np import matplotlib.pyplot as plt import cv2 as cv #this program conversts color of certain sections of image #each pixel is checked for the r g b and modified using a numpy array image = cv.imread('rg.png') #print(image.shape) #print(np.asarray(image)) width , height , channels = image.shape #print(width) #print(height) #print(channels) plt.imshow(image) plt.show() #print(image[29][29]) zero_array = np.zeros((2, 3, 3)) for pixeli in range(width):     #print(pixeli)     for pixelj in range(height):        # print(pixeli,pixelj)         #print(image[pixeli][pixelj])         pixelvalue = image[pixeli][pixelj]         #print(pixelvalue)         if pixelvalue[0] == 76 and pixelvalue[1] == 177 and pixelvalue[2] == 34:             #print('mach')             r = 0             g = 0             b = 0             image[pixeli][pixelj] = [r, g, b]   plt.imshow(image) plt.show() The pixel level color are changed as y

Raspberry pi

Raspberry pi is a computer which can easily run on linux os uses: can be used as a controller for projects  controller meaning send and receive data using raspberry pi to devices  for testing. can be used for developing prototypes. simply buy and start exploring the world simple as that. https://www.raspberrypi.org/products/   if your are interested in LINUX install in pi and use as a desktop computer.   https://ubuntu.com/download/raspberry-pi  https://ubuntu.com/download/iot Buy the latest raspberry -5 Select your country and reseller to buy directly from the reseller. https://www.raspberrypi.com/products/raspberry-pi-5/ Raspberry keyboard can be bought but my experience with the keyboard was boring and some keys were not working  It’s better to use other keyboards rather than this.   buy the new raspberry with higher configuration  8 Gb/quad core  enjoy - https://www.raspberrypi.com/products/raspberry-pi-400/