MCPcopy Index your code
hub / github.com/lazyprogrammer/machine_learning_examples / forward

Function forward

ann_class2/mlp.py:12–23  ·  view source on GitHub ↗
(X, W1, b1, W2, b2)

Source from the content-addressed store, hash-verified

10import numpy as np
11
12def forward(X, W1, b1, W2, b2):
13 # sigmoid
14 # Z = 1 / (1 + np.exp(-( X.dot(W1) + b1 )))
15
16 # relu
17 Z = X.dot(W1) + b1
18 Z[Z < 0] = 0
19
20 A = Z.dot(W2) + b2
21 expA = np.exp(A)
22 Y = expA / expA.sum(axis=1, keepdims=True)
23 return Y, Z
24
25def derivative_w2(Z, T, Y):
26 return Z.T.dot(Y - T)

Callers 3

mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected