Created
October 11, 2020 16:08
-
-
Save coreyjs/cca84457c46fd6d41a70ee586ade5b9b to your computer and use it in GitHub Desktop.
Sigmoid, yhat, error forumula and weight updating
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sigmoid(x): | |
return 1 / (1 + np.exp(-x)) | |
def output_formula(features, weights, bias): | |
return sigmoid(np.dot(features, weights) + bias) | |
def error_formula(y, output): | |
return - y*np.log(output) - (1 - y) * np.log(1-output) | |
def update_weights(x, y, weights, bias, learnrate): | |
output = output_formula(x, weights, bias) | |
d_error = y - output | |
weights += learnrate * d_error * x | |
bias += learnrate * d_error | |
return weights, bias |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment