Skip to content

Instantly share code, notes, and snippets.

@srikarplus
Created October 9, 2018 02:24
Show Gist options
  • Save srikarplus/ff6e64f35ce3444712b37c008f3b8349 to your computer and use it in GitHub Desktop.
Save srikarplus/ff6e64f35ce3444712b37c008f3b8349 to your computer and use it in GitHub Desktop.
neural network prediction
def predict(theta1, theta2, X, y):
m = len(y)
ones = np.ones((m,1))
a1 = np.hstack((ones, X))
a2 = sigmoid(a1 @ theta1.T)
a2 = np.hstack((ones, a2))
h = sigmoid(a2 @ theta2.T)
return np.argmax(h, axis = 1) + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment