Search the guide

Start with a guide

Lesson 2 of 14 · Basics · Python tutorial

Put a rule in weights

Write weights that implement a logical rule.

A threshold makes a decision#

A threshold neuron returns 1 when its weighted sum reaches zero, and 0 otherwise. For two binary inputs, weights [1, 1] and bias -1.5 implement AND: both inputs must be 1. Change the bias to -0.5 and the same neuron implements OR.

Check every input#

Python · NumPy
Ready to run

Output

Run the code to see its output.

Try this: Change the AND bias from -1.5 to -0.5. Which rows now return 1?

Runs in your browser. Ctrl/⌘ + Enter runs the code.

Combine neurons for another rule#

XOR returns 1 when exactly one input is 1. A hidden layer combines intermediate decisions to produce this rule.

Python · NumPy
Ready to run

Output

Run the code to see its output.

Try this: Change one hidden-layer bias and run all four cases again. Follow the intermediate decisions through the network.

Runs in your browser. Ctrl/⌘ + Enter runs the code.

Course contents