(X, W1, b1, W2, b2)
| 40 | return 1 / (1 + np.exp(-a)) |
| 41 | |
| 42 | def forward(X, W1, b1, W2, b2): |
| 43 | Z = sigmoid(X.dot(W1) + b1) # sigmoid |
| 44 | # Z = np.tanh(X.dot(W1) + b1) # tanh |
| 45 | # Z = np.maximum(X.dot(W1) + b1, 0) # relu |
| 46 | A = Z.dot(W2) + b2 |
| 47 | expA = np.exp(A) |
| 48 | Y = expA / expA.sum(axis=1, keepdims=True) |
| 49 | return Y |
| 50 | |
| 51 | # determine the classification rate |
| 52 | # num correct / num total |