Skip to content

Instantly share code, notes, and snippets.

@bobbywlindsey
Created October 7, 2019 21:29
Show Gist options
  • Save bobbywlindsey/1a2f7113590465f9beb509954e6c0f0d to your computer and use it in GitHub Desktop.
Save bobbywlindsey/1a2f7113590465f9beb509954e6c0f0d to your computer and use it in GitHub Desktop.
Perceptron inference
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