Created
October 7, 2019 21:29
-
-
Save bobbywlindsey/1a2f7113590465f9beb509954e6c0f0d to your computer and use it in GitHub Desktop.
Perceptron inference
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 activation(x, function_name): | |
if function_name == 'step': | |
return step(x) | |
elif function_name == 'sign': | |
return sign(x) | |
else: | |
raise NotImplementedError | |
def initialize_weights(num_columns): | |
return np.zeros(num_columns) | |
def predict(vector, weights, activation_function): | |
linear_sum = np.dot(weights, vector) | |
output = activation(linear_sum, activation_function) | |
return output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment