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/2020-03-02-linear-scratch_4_1.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)