Processing Mechanisms


A ProcessingMechanism is a type of Mechanism that transforms its input in some way. A ProcessingMechanism always receives its input either from another Mechanism, or from the input to a Process or System when it is executed. Similarly, its output is generally conveyed to another Mechanism or used as the output for a Process or System.

The ProcessingMechanism is the simplest mechanism in PsyNeuLink. It does not have any extra arguments or specialized validation. Almost any PsyNeuLink Function, including the UserDefinedFunction, may be the function of a ProcessingMechanism. Currently, the only exception is BackPropagation. Subtypes of ProcessingMechanism have more specialized features, and often have restrictions on which Functions are allowed.

The output of a ProcessingMechanism may also be used by an AdaptiveMechanism to modify the parameters of other components (or its own parameters). ProcessingMechanisms are always executed before all AdaptiveMechanisms in the Process and/or System to which they belong, so that any modifications made by the AdaptiveMechanism are available to all ProcessingMechanisms in the next TRIAL.

Creating a ProcessingMechanism

A ProcessingMechanism is created by calling its constructor.

Its function is specified in the function argument, which may be the name of a Function class:

>>> import psyneulink as pnl
>>> my_linear_processing_mechanism = pnl.ProcessingMechanism(function=pnl.Linear)

in which case all of the function’s parameters will be set to their default values.

Alternatively, the function argument may be a call to a Function constructor, in which case values may be specified for the Function’s parameters:

>>> my_logistic_processing_mechanism = pnl.ProcessingMechanism(function=pnl.Logistic(gain=1.0, bias=-4))


A ProcessingMechanism has the same basic structure as a Mechanism. See the documentation for individual subtypes of ProcessingMechanism for more specific information about their structure.


Three main tasks are completed each time a ProcessingMechanism executes:

1. The ProcessingMechanism updates its InputState`(s), and their values are used to assemble `variable. Each InputState value (often there is only one InputState) is added to an outer array, such that each item of variable corresponds to an InputState value.

2. The ProcessingMechanism’s variable is handed off as the input to the ProcessingMechanism’s function, and the function executes.

3. The result of the ProcessingMechanism’s function is placed in the Mechanism’s value attribute, and OutputStates are generated based on value.

A ProcessingMechanism may be executed by calling its execute method directly:

>>> my_simple_processing_mechanism = pnl.ProcessingMechanism()      
>>> my_simple_processing_mechanism.execute(1.0)                     

This option is intended for testing and debugging purposes.

More commonly, a mechanism is executed when the Process or System to which it belongs is run. A ProcessingMechanism always executes before any AdaptiveMechanisms in the same Process or System.

class psyneulink.components.mechanisms.processing.processingmechanism.ProcessingMechanism(default_variable=None, size=None, function=Linear, params=None, name=None, prefs=None)

Subclass of ProcessingMechanism that does not have any specialized features.

  • default_variable (number, list or np.ndarray) – the input to the Mechanism to use if none is provided in a call to its execute or run methods; also serves as a template to specify the length of variable for function, and the primary outputState of the Mechanism.
  • size (int, list or np.ndarray of ints) –

    specifies default_variable as array(s) of zeros if default_variable is not passed as an argument; if default_variable is specified, it takes precedence over the specification of size. As an example, the following mechanisms are equivalent:

    P1 = ProcessingMechanism(size = [3, 2])
    P2 = ProcessingMechanism(default_variable = [[0, 0, 0], [0, 0]])
  • function (PsyNeuLink Function : default Linear) – specifies the function used to compute the output
  • params (Dict[param keyword: param value] : default None) – a parameter dictionary that can be used to specify the parameters for the Mechanism, parameters for its function, and/or a custom function and its parameters. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
  • name (str : default see name) – specifies the name of the ProcessingMechanism.
  • prefs (PreferenceSet or specification dict : default Mechanism.classPreferences) – specifies the PreferenceSet for the ProcessingMechanism; see prefs for details.

value: default – the input to Mechanism’s function.


str – the name of the ProcessingMechanism; if it is not specified in the name argument of the constructor, a default is assigned by MechanismRegistry (see Naming for conventions used for default and duplicate names).


PreferenceSet or specification dict – the PreferenceSet for the ProcessingMechanism; if it is not specified in the prefs argument of the constructor, a default is assigned using classPreferences defined in (see PreferenceSet for details).