slpNNCAG: A Neural Network with Competitive Attentional Gating (NNCAG)

View source: R/RcppExports.R

slpNNCAGR Documentation

A Neural Network with Competitive Attentional Gating (NNCAG)


This is Model 4 from Paskewitz and Jones (2020). Model 4 is a Neural Network with Competitive Attentional Gating - a fragmented version of EXIT (Kruschke, 2001) lacking exemplar-based rapid attentional shifts.


slpNNCAG(st, tr, xtdo = FALSE)



List of model parameters


R matrix of training items


Boolean specifying whether to include extended information in the output (see below).


The function operates as a stateful list processor (slp; see Wills et al., 2017). Specifically, it takes a matrix (tr) as an argument, where each row represents a single training trial, while each column represents the different types of information required by the model, such as the elemental representation of the training stimuli, and the presence or absence of an outcome.

Argument st must be a list containing the following items:

P - attention normalization constant, P.

phi - decision-making constant, φ, also referred to as specificity constant.

lambda - learning rate, λ.

mu - attentional learning rate, μ.

outcomes - The number of categories.

w - a k by i matrix of initial weights, where k equals to the number of categories and i equals to the number of stimuli.

eta - η, a vector with i elements, where η -th is the salience of the i -th cue. In edge cases, η is capped at lower bound of 0.1, see Note 1.

colskip - The number of optional columns to be skipped in the tr matrix. colskip should be set to the number of optional columns you have added to the tr matrix, PLUS ONE. So, if you have added no optional columns, colskip=1. This is because the first (non-optional) column contains the control values (details below).

Argument trmust be a matrix, where each row is one trial presented to the model. Trials are always presented in the order specified. The columns must be as described below, in the order described below:

ctrl - a vector of control codes. Available codes are: 0 = normal trial; 1 = reset model (i.e. set matrix of initial weights and vector of salience back to their initial values as specified in st); 2 = Freeze learning. Control codes are actioned before the trial is processed.

opt1, opt2, ... - any number of preferred optional columns, the names of which can be chosen by the user. It is important that these columns are placed after the control column, and before the remaining columns (see below). These optional columns are ignored by the function, but you may wish to use them for readability. For example, you might choose to include columns such as block number, trial number and condition. The argument colskip (see above) must be set to the number of optional columns plus one.

x1, x2, ... - columns for each cue (1 = cue present, 0 = cue absent). There must be one column for each input element. Each row is one trial. In simple applications, one element is used for each stimulus (e.g. a simulation of blocking (Kamin, 1969), A+, AX+, would have two inputs, one for A and one for X). In simple applications, all present elements have an activation of 1 and all absent elements have an activation of 0. However, slpNNCAG supports any real number for activations.

t1, t2, ... - columns for the teaching values indicating the category feedback on the current trial. Each category needs a single teaching signal in a dummy coded fashion, e.g., if there are four categories and the current stimulus belongs to the second category, then we would have [0, 1, 0, 0].


Returns a list containing three components (if xtdo = FALSE) or four components (if xtdo = TRUE).

if xtdo = FALSE:


Response probabilities for each trial (rows) and each category (columns).


Salience at the end of training. η for each stimulus i.


An k by i weight matrix at the end of training, where rows are categories and columns are stimuli. Order of stimuli and categories correspond to their order in tr.

if xtdo = TRUE, the following values are also returned:


The matrix for trial-level predictions of the model as specified by Equation 5 in Paskewitz and Jones (2021).


The updated salience at the end of each trial.


1. If there is only one stimulus present on a given trial with η = 0 or with g = 0, Equation 12 of Paskewitz & Jones (2020) breaks down. In order to avoid this, eta and g are capped at the lower limit of 0.01.

2. This model is implemented in C++ for speed.


Lenard Dome, Andy Wills


Kamin, L.J. (1969). Predictability, surprise, attention and conditioning. In Campbell, B.A. & Church, R.M. (eds.), Punishment and Aversive Behaviour. New York: Appleton-Century-Crofts, 1969, pp.279-296.

Kruschke, J. K. (2001). Toward a unified model of attention in associative learning. Journal of Mathematical Psychology, 45(6), 812-863.

Paskewitz, S., & Jones, M. (2020). Dissecting EXIT. Journal of Mathematical Psychology, 97, 102371.

Wills, A.J., O'Connell, G., Edmunds, C.E.R., & Inkster, A.B.(2017). Progress in modeling through distributed collaboration: Concepts, tools, and category-learning examples. Psychology of Learning and Motivation, 66, 79-115.

See Also


catlearn documentation built on March 26, 2022, 1:07 a.m.