How to Use Neuron Sandbox

Neuron Sandbox teaches how a single linear threshold unit — the basic building block of neural network technology powering much of modern AI — computes the answers to decision problems. It can be used from upper elementary school through undergraduate computing education. It comes with a set of pre-defined problems of increasing difficulty, but it also offers a convenient editing mode for creation of new problems without any coding. New problems can be saved to a file and loaded them from either a file path or a URL.

Resources for Teachers

Solve for Weights/Threshold

"Solve for Weights" is the default mode for Neuron Sandbox. It presents a table of example inputs and desired outputs and invites the user to modify one or more of the neuron's weights and/or its threshold to achieve the desired behavior. Any rows (examples) that are not being processed correctly are flagged in red.

Problems are presented in order of increasing difficulty. The simplest problems have two symmetric positive weights, a non-negative threshold, and only ask the user to modify a single parameter.

The "How does this work?" button toggles display of an explicit equation for the neuron's activation value. The equation multiplies each input by its respective weight. The Greek letter Σ denotes this activation value. Rather than specifying a summation, Σ stands for the result of the summation.

The Hint button displays a hint about which parameter to modify. Pressing it again provides a more explicit hint: whether the parameter should be increased or decreased. Hints are computed automatically based on the current parameter values.

As students become familiar with linear threshold units they will discover some helpful rules of thumb, or they can be taught these rules explicitly. Here are two of them:

  • If an all-zero input (first row of the inputs table) is required to produce a 1 as output, the unit's threshold value must be negative.

  • When comparing two rows of the inputs table, if changing a single input from 0 to 1 causes the corresponding desired output to change from 1 to 0, that input must have a negative weight.

Solve for Outputs

Some students need practice mapping between an English description of a problem and the corresponding truth table. This may impede their ability to solve for weights and threshold because they must rely on the "Desired Output" display, which may conflict with their mistaken intuition about what the output should be.

"Solve for Outputs" mode allows students to practice predicting the correct output for a given input pattern by having them fill in the truth table values themselves. The "Press to Check" button can be used to verify the correctness of the user's answers. Optionally, the problem creator can attach a hint to each row of the table to help students understand the justification for each answer. Once the truth table is filled correctly the user is invited to switch to solving for the weights and threshold.

If you want a given problem to start out in "Solve for Outputs" mode when first loaded, switch to that mode before saving the problem to a file.

Solve for Boundary

For 2-input problems, "Solve for Boundary" mode displays the decision boundary as a blue line and the input cases as points in the plane. The half of the plane where the unit's net activation is positive (so the output will be 1) is shown in green; the other half is shown in red. Sliders provide direct control of the weights and threshold/bias. It's also possible to move the decision boundary directly by clicking on one of the blue square control points (which will turn yellow) and then clicking again to indicate where the point should move to. The middle control point adjusts only the threshold, while the other two adjust both the weights and threshold. The "Flip Sign" button flips the signs of the weights and threshold, which leaves the boundary unchanged but swaps the red and green regions in the plot.

For 1-input problems the two input points are plotted on a number line and the decision boundary is a blue bisector of that line.

Support for 3-input problems is in development.

Threshold Display vs. Bias Display

Normally Neuron Sandbox displays a threshold value inside the neuron body. The activation value is compared against this threshold. But real neural networks don't use adjustable thresholds; they use a bias connection instead, with the threshold fixed at 0. If "Show Bias" is enabled for a problem, there will be a slider allowing the user to switch the display between "Threshold mode" and "Bias mode".

In "Bias mode" the effective threshold value θ is displayed as a weight –θ on a bias connection whose input is fixed at 1, and the actual threshold is fixed at 0. Note that switching modes only affects the display; it does not affect the operation of the neuron. The neuron will produce the same outputs in either mode. But the activation values and threshold are different.

Non-Binary Inputs

By default Neuron Sandbox assumes its inputs are binary values, which allows it to automatically generate a complete truth table with 2N rows for N inputs. However, if "Binary Mode" is turned off, then the inputs can be any real value, and the numer of rows in the example table, and their content, must be specified by the problem designer.

Note that the neuron is still a linear threshold unit producing binary outputs. But using non-binary inputs allows for the solution of problems such as "The class can go on a trip if the number of chaperones x1 is at least as great as the number of chidren x2."

Creating New Problems

To create a new problem, select "Blank Model" from the problem list, and then from the Menu, enabled "Edit Mode". You can change the names of the inputs by editing the text in the input table header. You can control which parameters are user-modifiable by clicking on the pencil or lock icon next to that parameter. There are a variety of other settings you can adjust, such as whether to use Threshold Mode or Bias Mode, binary inputs or real-valued inputs, and whether a victory fanfare should be played when a problem is solved correctly.

To provide hints for Solve for Outputs mode, switch to that mode and edit the contents of the text box associated with each row. Note that this are different than the hint produced by the Hint button when solving for weights and threshold; those hints are computed automatically.

Once the problem setup us complete, save the problem to a file on the local disk. It can then be loaded from that location at a later time, or placed on a website and oaded via the URL.


Credits and Source Code

Authors: Angela Chen, Neel Pawar, and David S. Touretzky, Carnegie Mellon University.

This work was supported by National Science Foundation awards DRL-2049029 and IIS-2112633.

Source code for Neuron Sandbox is available on GitHub at https://github.com/touretzkyds/NeuronSandbox.