MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / forward

Function forward

ann_class/xor_donut.py:19–32  ·  view source on GitHub ↗
(X, W1, b1, W2, b2)

Source from the content-addressed store, hash-verified

17# for binary classification! no softmax here
18
19def forward(X, W1, b1, W2, b2):
20 # sigmoid
21 # Z = 1 / (1 + np.exp( -(X.dot(W1) + b1) ))
22
23 # tanh
24 # Z = np.tanh(X.dot(W1) + b1)
25
26 # relu
27 Z = X.dot(W1) + b1
28 Z = Z * (Z > 0)
29
30 activation = Z.dot(W2) + b2
31 Y = 1 / (1 + np.exp(-activation))
32 return Y, Z
33
34
35def predict(X, W1, b1, W2, b2):

Callers 3

predictFunction · 0.70
test_xorFunction · 0.70
test_donutFunction · 0.70

Calls

no outgoing calls

Tested by 2

test_xorFunction · 0.56
test_donutFunction · 0.56