Skip to content

Instantly share code, notes, and snippets.

@hackintoshrao
Created December 21, 2017 00:04
Show Gist options
  • Save hackintoshrao/d66d74ed32cfee9cfe65fdb877f1d603 to your computer and use it in GitHub Desktop.
Save hackintoshrao/d66d74ed32cfee9cfe65fdb877f1d603 to your computer and use it in GitHub Desktop.
NOT perceptron on input 2.
import pandas as pd
weight1 = 0.0
weight2 = -2.0
bias = 1.0
# DON'T CHANGE ANYTHING BELOW
# Inputs and outputs
test_inputs = [(0, 0), (0, 1), (1, 0), (1, 1)]
correct_outputs = [True, False, True, False]
outputs = []
# Generate and check output
for test_input, correct_output in zip(test_inputs, correct_outputs):
linear_combination = weight1 * test_input[0] + weight2 * test_input[1] + bias
output = int(linear_combination >= 0)
is_correct_string = 'Yes' if output == correct_output else 'No'
outputs.append([test_input[0], test_input[1], linear_combination, output, is_correct_string])
# Print output
output_frame = pd.DataFrame(outputs, columns=['Input 1', ' Input 2', ' Linear Combination', ' Activation Output', ' Is Correct'])
print(output_frame.to_string(index=False))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment