Gating Mechanism

Overview

A GatingMechanism is an AdaptiveMechanism that modulates the value of the InputState(s) and/or OutputState(s) of one or more Mechanisms. Its function takes the GatingMechanism’s variable and uses that generate a gating_policy: a list of values, one for each of its GatingSignals. Each of those, in turn, generates a gating_signal used by its GatingProjections to modulate the value of the State( s) to which they project. A GatingMechanism can regulate only the parameters of Mechanisms in the System to which it belongs. The InputStates and/or OutputStates gated by a GatingMechanism can be list using its show method.

The gating components of a System are executed after all ProcessingMechanisms, LearningMechanism, and ControlMechanism in that System have been executed.

Creating A GatingMechanism

GatingMechanism can be created using the standard Python method of calling the constructor for the desired type. A GatingMechanism is also created automatically if gating is specified for an InputState, OutputState or Mechanism, in which case a GatingProjection is automatically created that projects from the GatingMechanism to the specified target

Specifying gating

GatingMechanism are used to modulate the value of an InputState or OutputState. An InputState or OutputState can be specified for gating by assigning it a GatingProjection or GatingSignal anywhere that the Projections to a State or its ModulatorySignals can be specified. A Mechanism can also be specified for gating, in which case the primary InputState of the specified Mechanism is used. States (and/or Mechanisms) can also be specified in the gating_signals argument of the constructor for a GatingMechanism. The gating_signals argument must be a list, each item of which must refer to one or more States (or the Mechanism(s) to which they belong) to be gated by that GatingSignal. The specification for each item in the list can use any of the forms used to specify a GatingSignal.

GatingSignals

A GatingSignal is created for each item listed in the gating_signals argument of the constructor, and all of the GatingSignals for a GatingMechanism are listed in its gating_signals attribute. Each GatingSignal is assigned one or more GatingProjections to the InputState(s) and/or OutputState(s) it gates.

Modulation

Each GatingMechanism has a modulation attribute, that provides a default for the way in which its GatingSignals modulate the value of the States they gate (see modulation for an explanation of how this attribute is specified and used to modulate the value of a State). Each GatingSignal uses this value, unless its value is individually specified.

Structure

Input

By default, a GatingMechanism has a single InputState, the value of which is used as the input to the GatingMechanism’s function.

Function

A GatingMechanism’s function uses the value of its primary InputState to generate an gating_policy. The default function for a GatingMechanism is a Linear identity function, that simply takes the value of its primary InputState and assigns this as the single item of its gating_policy. This can be replaced by a Functions that generates a gating_policy with multiple values, which may be useful if the GatingMechanism is assigned more than one GatingSignal. .. _GatingMechanism_Output:

Output

A GatingMechanism has a GatingSignal for each InputState and/or OutputState specified in its gating_signals attribute, to which it sends a GatingProjection. If the GatingMechanism’s function generates a gating_policy with a single value (the default), then this is used as the value of all of the GatingMechanism’s gating_signals. If the gating_policy has multiple items, and this is the same as the number of GatingSignals, then each GatingSignal is assigned the value of the corresponding item in the gating_policy. If there is a different number of gating_signals than the number of items in the gating_policy, then the index attribute of each GatingSignal must be specified (e.g., in a specification dictionary in the gating_signal argument of the GatingMechanism’s constructor), or an error is generated. The GatingSignals of a GatingMechanism are listed in its gating_signals attribute. Since GatingSignals are a type of OutputState, they are also listed in the GatingMechanism’s output_states attribute. The InputStates and/or OutputStates modulated by a GatingMechanism’s GatingSignals can be displayed using its show method.

Execution

A GatingMechanism executes in the same way as a ProcessingMechanism, based on its place in the System’s graph. Because GatingProjections are likely to introduce cycles (recurrent connection loops) in the graph, the effects of a GatingMechanism and its projections will generally not be applied in the first TRIAL (see initialization for a description of how to configure the initialization of feedback loops in a System; also see Scheduler for a description of detailed ways in which a GatingMechanism and its dependents can be scheduled to execute).

When executed, a GatingMechanism uses its input to determine the value of its gating_policy, each item of which is used by a corresponding GatingSignal to determine its gating_signal and assign to its GatingProjections. In the subsequent TRIAL, each GatingProjection’s value is used by the State to which it projects to modulate the value of that State (see modulation fon an explanation of how the value of a State is modulated).

Note

A State that receives a GatingProjection does not update its value (and therefore does not reflect the influence of its GatingSignal) until that State’s owner Mechanism executes (see Lazy Evaluation for an explanation of “lazy” updating).

Class Reference

class psyneulink.components.mechanisms.adaptive.gating.gatingmechanism.GatingMechanism(default_gating_policy=None, size=None, function=Linear(slope=1, intercept=0), gating_signals:tc.optional(list) = None, modulation=ModulationParam.MULTIPLICATIVE, params=None, name=None, prefs=None)

Subclass of AdaptiveMechanism that gates (modulates) the value(s) of one or more States.

Parameters:
  • default_gating_policy (value, list or ndarray : default defaultGatingPolicy) – the default value for each of the GatingMechanism’s GatingSignals; its length must equal the number of items specified in the gating_signals argument.
  • size (int, list or 1d np.array of ints) –

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

    T1 = TransferMechanism(size = [3, 2])
    T2 = TransferMechanism(default_variable = [[0, 0, 0], [0, 0]])
    
  • function (TransferFunction : default Linear(slope=1, intercept=0)) – specifies the function used to transform the GatingMechanism’s variable to a gating_policy.
  • gating_signals (List[GatingSignal, InputState, OutputState, Mechanism, tuple[str, Mechanism], or dict]) – specifies the InputStates and/or OutputStates to be gated by the GatingMechanism; the number of items must equal the length of the default_gating_policy argument; if a Mechanism is specified, its primary InputState is used (see `GatingMechanism_GatingSignals for details).
  • modulation (ModulationParam : ModulationParam.MULTIPLICATIVE) – specifies the default form of modulation used by the GatingMechanism’s GatingSignals, unless they are individually specified.
  • 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 GatingMechanism.
  • prefs (PreferenceSet or specification dict : default Mechanism.classPreferences) – specifies the PreferenceSet for the GatingMechanism; see prefs for details.
variable

value, list or ndarray – used as the input to the GatingMechanism’s function. Its format is determined by the default_gating_policy or size argument of the GatingMechanism’s constructor (see above), and is the same format as its gating_policy (unless a custom function has been assigned).

function

TransferFunction – determines the function used to transform the GatingMechanism’s variable to a gating_policy; the default is an identity function that simply assigns variable as the gating_policy.

gating_signals

ContentAddressableList[GatingSignal] – list of GatingSignals for the GatingMechanism, each of which sends GatingProjection(s) to the InputState(s) and/or OutputStates that it gates; same as GatingMechanism output_states attribute.

gating_projections

List[GatingProjection] – list of all of the GatingProjections assigned to the GatingMechanism’s GatingSignals (i.e., listed in its gating_signals attribute.

value

scalar or 1d np.array of ints – the result of the GatingMechanism’s function; each item is the value assigned to the corresponding GatingSignal listed in gating_signals, and used by each GatingSignal to generate the gating_signal assigned to its GatingProjections; same as the GatingMechanism’s gating_policy attribute. Default is a single item used by all of the gating_signals.

gating_policy

scalar or 1d np.array of ints – the result of the GatingMechanism’s function; each item is the value assigned to the corresponding GatingSignal listed in gating_signals, and used by each GatingSignal to generate the gating_signal assigned to its GatingProjections; same as the GatingMechanism’s value attribute. Default is a single item used by all of the gating_signals.

modulation : ModulationParam
the default form of modulation used by the GatingMechanism’s GatingSignals, unless they are individually specified.
name : str
the name of the GatingMechanism; 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).
prefs : PreferenceSet or specification dict
the PreferenceSet for the GatingMechanism; if it is not specified in the prefs argument of the constructor, a default is assigned using classPreferences defined in __init__.py (see PreferenceSet for details).
outputStateType

alias of GatingSignal

show()

Display the InputStates and/or OutputStates gated by the GatingMechanism’s gating_signals.