26 lines
402 B
Python
26 lines
402 B
Python
|
import numpy as np
|
||
|
|
||
|
def relu(y):
|
||
|
return np.maximum(0, y)
|
||
|
|
||
|
def layer(W, x, b):
|
||
|
return relu(W @ x + b)
|
||
|
|
||
|
n = [64,128,128,128,10]
|
||
|
|
||
|
print(f"Dimensions: {n}")
|
||
|
|
||
|
# First layer
|
||
|
x = np.random.rand(n[0])
|
||
|
b = np.random.rand(n[1])
|
||
|
y = np.random.rand(128,64)
|
||
|
|
||
|
y = layer(y, x, b)
|
||
|
|
||
|
for i in range(2, len(n)):
|
||
|
W = np.random.rand(n[i], n[i - 1])
|
||
|
b = np.random.rand(n[i])
|
||
|
y = layer(W, y, b)
|
||
|
|
||
|
print(y)
|