Skip to content

Commit

Permalink
priming fully updated and clarified
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoreilly committed Nov 11, 2024
1 parent 96b9753 commit 0b91737
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 12 additions & 12 deletions ch7/priming/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,47 +36,47 @@ We will first see if we can prime the `B` outputs by a single training trial on

First we need to establish a baseline measure of the extent to which the network at the end of training responds with either the `A` or `B` output.

* Select the `Test Trial Plot` to view the testing results, and then set the `Step` to `Epoch` and click `Step` to train one epoch with both `A` and `B` items as targets (i.e,. the `TrainAll` environment, that was used originally). It will automatically run the test after each epoch, so you will see the plot update.
* Select the `Test Trial Plot` to view the testing results, where the network is tested on the `OnlyA` patterns to determine how many times it responds with an A or B to the 12 input patterns. Then set the `Step` to `Epoch` and click `Step` to train one epoch with both `A` and `B` items as targets (i.e,. the `Alt AB` environment, that was used during training). It will automatically run the test after each epoch, so you will see the plot update.

This plot shows for each input (0-12) whether it responded with the A output (`IsA`) in the minus phase (i.e., `ActM`) and also gives the name of the closest output (`Closest`) for visual concreteness. You should see that it responds with the `a` output on roughly half of the trials (there is no bias in the training -- it can randomly vary quite a bit though).

Next, we will change the training so that it only presents `B` output items.

* Click the `Set Env` button in the toolbar, and select `TrainB` -- this will configure to train on the `B` items only. Then do `Step Epoch` again.

The extent of priming is indicated by the *reduction* in `IsA` responses -- the network should respond `b` more frequently (even exclusively), based on a single learning experience with a relatively small learning rate.
The extent of priming is indicated by the *reduction* in `IsA` responses -- the network should respond `b` more frequently, based on a single learning experience with a relatively small learning rate. If you do another `Step Epoch`, almost all of the responses should now be `b`.

To make sure this was not just a fluke, let's try to go the other way, and see how many of the current `b` responses can be flipped back over to `a` with a single exposure to the `a` outputs.

* Click `Set Env` and this time select the `TrainA`. Then `Step Epoch`.

You should see a large number of the `b` responses have now flipped back to `a`, again based on a single exposure.
You should see that some of the `b` responses have now flipped back to `a`, again based on a single exposure.

You can repeat this experiment a couple more times, flipping the `a`'s back to `b`'s, and then back to `a`'s again.

* Click the `Test Epoch Plot` tab see a plot of all the testing results in summary form.

> **Question 7.7:** Report the IsA results for each of the 3 data points, corresponding to TrainAll, TrainB, and TrainA (hover the mouse over the points to get the numbers, or click the `Table` button to see a table of the numbers).
> **Question 7.7:** Report the IsA results for each of the 3 data points, corresponding to TrainAltAB, TrainB, and TrainA (hover the mouse over the points to get the numbers, or click the `Table` button to see a table of the numbers).
You can optionally explore turning the `Lrate` parameter down to .01 or even lower (we are applying the parameters every trial so you don't need to do `Init` to get the parameter to take effect). You should see that although the number of items that flip is reduced, even relatively low lrates can produce flips.

# Activation-Based Priming

Next, we can see to what extent residual activation from one trial to the next can bias processing. To set up this test, we want the network to have a weight-based bias to respond with the `b` output:
Next, we can see to what extent residual activation from one trial to the next can bias processing. We'll start over with the trained weights.

* Click `Set Env` and select `TrainB`, and do `Step Epoch`, to ensure that it generally responds `b`. (If you experimented with learning rate, or did a lot of tests with the weight-based case, it might be better to start fresh with `Init`, `Open Trained Wts` and then `Step Epoch` with the `TrainB` until you see that it generally responds to `b`).
* Click `Init` while still in `Train` mode, and then do `Open Trained Wts`.

Next, we will use the `TrainAll` patterns for testing, because they alternate between the `a` and `b` versions of each input when presented sequentially -- we will test for the extent to which the residual activation from the `a` item can bias processing on the subsequent `b` case. Note that we are recording the response of the network in the *minus* phase, and then the specific `Output` is clamped in the plus phase (even during testing), so we can observe the effects of e.g., the `0_a` `Output` activation (with the `a` pattern) on the tendency to bias the network to produce an `a` response again for the 0 input, despite the weights being biased in favor of producing the `b` output.
Next, we will use the `AltAB` patterns for testing, because they alternate between the `a` and `b` versions of each input when presented sequentially, and we can see the effect of the the `a` input on the first trial on the second trial of the same input pattern. We will test for the extent to which the residual activation from the first `a` item can bias processing on the subsequent `b` case. Note that we are recording the response of the network in the _minus_ phase, and then the specific `Output` is clamped in the plus phase (even during testing), so we can observe the effects of e.g., the `0_a` `Output` activation (with the `a` pattern) on the tendency to bias the network to produce an `a` response again for the second 0 input. Therefore, we are looking specifically at the response on the second presentation of the same input in these alternating A, B patterns, which, confusingly enough, is labeled as `b` -- if there is activation priming, this second trial should be more likely to be an `a`.

* Click `Set Env` and select `TestAll` to use this full set of alternating `TrainAll` patterns during _testing_, and then switch to `Test` instead of `Train` mode, and do `Init` (which will not initialize the weights because we are in `Test` mode), `Run` to see the baseline level of responding, while looking at the `Test Trial Plot`.
* Click `Set Env` and select `Test alt AB` to use this full set of alternating `AltAB` patterns during _testing_, and then switch to `Test` instead of `Train` mode, and do `Init` (which will not initialize the weights because we are in `Test` mode), `Run` to see the baseline level of responding, while looking at the `Test Trial Plot`.

This is a baseline, because we are still clearing all of the activation out of the network between each input, due to the `Decay` parameter being set to the default of 1.
This is a baseline, because we are still clearing all of the activation out of the network between each input, due to the `Decay` parameter being set to the default of 1. You should see that the network responds _consistently_ to both instances of the same input pattern. For example, if it responds `a` to the first `0` input, then it will also respond `a` to the second one right after that. There is no evidence of activation priming here.

* Set `Decay` to 0 instead of 1, and do another `Init` and `Run`. You should now observe several trials in which the `a` pattern is activated, for the 2nd of the two repeated inputs.
* Set `Decay` to 0 instead of 1, and do another `Init` and `Run`. You should now observe a very different pattern, where the responses to the second input of the same pattern are more likely to be `a`. This looks like a "sawtooth" kind of jaggy pattern in the test plot.

> **Question 7.8:** Report the number of times the network responded 'a' instead of 'b' for the 'b' test trials, relative to the baseline that you observed above with Decay set to 1.
> **Question 7.8:** Looking only at the 2nd instance of each input pattern, report the number of times the network responded 'a' instead of 'b' for the 'b' test trials, relative to the baseline that you observed above with Decay set to 1 (you can go back and forth between Decay = 1 vs. 0 -- in Test mode there is no learning so the results should be consistent).
You can explore extent of residual activity needed to show this activation-based priming by adjusting the `Decay` parameter and running `Test` again (no learning takes place during testing so you can explore at will, and go back and verify that Decay = 1 still produces mostly `b`'s). In our tests increasing Decay using this efficient search sequence: 0, .5, .8, .9, .95, .98, .99, we found a critical transition between .98 and .99 -- i.e., a very tiny amount of residual activation with .98 (= .02 residual activity) was capable of driving a surprisingly large amount of activation-based priming. This suggests that the network is delicately balanced between the two attractor states and even a very tiny bias can push it one way or the other. The similar susceptibility of the human brain to such activation-based priming effects suggests that it too may exhibit a similar attractor balancing act.
You can explore extent of residual activity needed to show this activation-based priming by adjusting the `Decay` parameter and running `Test` again (no learning takes place during testing so you can explore at will, and go back and verify that Decay = 1 still produces mostly `b`'s). In our tests increasing Decay using this efficient search sequence: 0, .5, .8, .9, .95, .98, .99, we found a critical transition between .98 and .99 -- i.e., a very tiny amount of residual activation with .98 (= .02 residual activity) was capable of driving some activation-based priming. This suggests that the network is delicately balanced between the two attractor states and even a very tiny bias can push it one way or the other. The similar susceptibility of the human brain to such activation-based priming effects suggests that it too may exhibit a similar attractor balancing act.

# References

Expand Down
2 changes: 2 additions & 0 deletions ch7/priming/priming.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,8 @@ func (ss *Sim) ApplyInputs() {
ev := ss.Envs.ByMode(ctx.Mode).(*env.FixedTable)
ev.Step()

ss.ApplyParams()

lays := net.LayersByType(leabra.InputLayer, leabra.TargetLayer)
net.InitExt()
ss.Stats.SetString("TrialName", ev.TrialName.Cur)
Expand Down

0 comments on commit 0b91737

Please sign in to comment.