import numpy as np
import matplotlib.pyplot as plt
%matplotlib inlinedef 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)
X.shape(4, 2)
Xarray([[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)