Search the guide

Start with a guide

Lesson 3 of 14 · Basics · Python tutorial

Construct once, run repeatedly

Separate making the weights from using them.

Two different operations#

Construction produces the parameters. Execution applies those parameters to a new input. For an affine function y = scale × x + shift, a constructor can put the scale into a weight matrix and the shift into a bias.

Make a function, then call it#

Python · NumPy
Ready to run

Output

Run the code to see its output.

Try this: Change the scale or shift and run again. Then keep w and b fixed and add a second mlp call with new inputs.

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

Reuse the constructed program#

The constructed weights survive between calls. New inputs use the same computation. This small example makes the boundary visible: the constructor chooses the parameters; the receiving network uses them.

Course contents