Neural Networks from scratch#

Simple scripts for downloading weather data

  • toc: true

  • badges: true

  • comments: true

  • author: Nipun Batra

  • categories: [ML]

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
def relu(x):
    return np.max(0, x)
X = np.array([[0, 0],
             [0, 1],
             [1, 0],
             [1, 1]])
y = np.array([0, 1, 1, 0])
plt.scatter(X[:, 0], X[:, 1],c=y)
<matplotlib.collections.PathCollection at 0x120334d50>
../../_images/b4a6f500f5001bb1925bfd025e97aa5101a96565e9739e5ab8afa74f5b761538.png
X.shape
(4, 2)
X
array([[0, 0],
       [0, 1],
       [1, 0],
       [1, 1]])
layers = [2, 1]
B = [np.zeros(n) for n in layers]
W = [None]*len(layers)
W[0] = np.zeros((X.shape[1], layers[0]))
W
[array([[0., 0.],
        [0., 0.]]), None]
for i in range(1, len(layers)):
    W[i] = np.zeros((layers[i-1], layers[i]))
W[1]
array([[0.],
       [0.]])
X.shape, W[0].shape
((4, 2), (2, 2))
X.shape
(4, 2)