(Y, P)
| 51 | # determine the classification rate |
| 52 | # num correct / num total |
| 53 | def classification_rate(Y, P): |
| 54 | n_correct = 0 |
| 55 | n_total = 0 |
| 56 | for i in range(len(Y)): |
| 57 | n_total += 1 |
| 58 | if Y[i] == P[i]: |
| 59 | n_correct += 1 |
| 60 | return float(n_correct) / n_total |
| 61 | |
| 62 | P_Y_given_X = forward(X, W1, b1, W2, b2) |
| 63 | P = np.argmax(P_Y_given_X, axis=1) |