# Projections¶

## Overview¶

Projections allow information to be passed between Mechanisms. A Projection takes its input from its sender and transmits that information to its receiver. The sender and receiver of a Projection are always States: the sender is always the OutputState of a Mechanism; the receiver depends upon the type of Projection. There are two broad categories of Projections, each of which has subtypes that differ in the type of information they transmit, how they do this, and the type of State to which they project (i.e., of their receiver):

## Creating a Projection¶

A Projection can be created on its own, by calling the constructor for the desired type of Projection. More commonly, however, Projections are either specified in context, or are created automatically, as described below.

### Specifying a Projection¶

Projections can be specified in a number of places where they are required or permitted, for example in the specification of a pathway for a Process, where the value of a parameter is specified (e.g., to assign a ControlProjection) or where a MappingProjection is specified (to assign it a LearningProjection). Any of the following can be used to specify a Projection in context:

• Constructor – used the same way in context as it is ordinarily.
• Projection object – must be a reference to a Projection that has already been created.
• Projection subclass – creates a default instance of the specified Projection type. The assignment or creation of the Projection’s sender is handled in the same manner as described below for keyword specifications.
• State – creates a Projections to or from the specified States, depending on the type of State and the context of the specification.
• Specification dictionary – can contain an entry specifying the type of Projection, and/or entries specifying the value of parameters used to instantiate it. These should take the following form:

• PROJECTION_PARAMS: Dict[Projection argument, argument value] – the key for each entry of the dictionary must be the name of a Projection parameter, and its value the value of the parameter. It can contain any of the standard parameters for instantiating a Projection (in particular its sender and receiver, or ones specific to a particular type of Projection (see documentation for subclass). If the sender and/or receiver are not specified, their assignment and/or creation are handled in the same manner as described above for keyword specifications.
• ProjectionTuple – a 4-item tuple used in the context of a State specification to create a Projection between it and another State. It must have at least the first three of the following items in order, and can include the fourth optional item:

• State specification – specifies the State to connect with (not the one being connected; that is determined from context)

• weight – must be a value specifying the weight of the Projection; it can be None, in which case it is ignored, but there must be a specification present;

• exponent – must be a value specifying the exponent of the Projection; it can be None, in which case it is ignored, but there must be a specification present;

• Projection specification – this is optional but, if included, msut be a Projection specification; it can take any of the forms of a Projection specification described above for any Projection subclass; it can be used to provide additional specifications for the Projection, such as its matrix if it is a MappingProjection.

Note

A ProjectionTuple should not be confused with a 4-item InputState specification tuple, which also contains weight and exponent items. In a ProjectionTuple, those items specify the weight and/or exponent assigned to the Projection (see Weight and Exponent), whereas in an InputState specification tuple they specify the weight and/or exponent of the InputState.

Any (but not all) of the items can be None. If the State specification is None, then there must be a Projection specification (used to infer the State to be connected with). If the Projection specification is None or absent, the State specification cannot be None (as it is then used to infer the type of Projection). If weight and/or exponent is None, it is ignored. If both the State and Projection are specified, they must be compatible (see examples in State).

### Automatic creation¶

Under some circumstances Projections are created automatically. For example, a Process automatically creates a MappingProjection between adjacent ProcessingMechanisms in its pathway if none is specified; and LearningProjections are automatically created when learning is specified for a Process or System).

### Deferred Initialization¶

When a Projection is created, its full initialization is deferred until its sender and receiver have been fully specified. This allows a Projection to be created before its sender and/or receiver have been created (e.g., before them in a script), by calling its constructor without specifying its sender or receiver arguments. However, for the Projection to be operational, initialization must be completed by calling its _deferred_init method. Under most conditions this occurs automatically (e.g., when the projection is assigned to a type of Component that expects to be the sender or receiver for that type of Projection); these conditions are described in the section on Deferred Initialization for each type of Projection. Otherwise, the Projection’s _deferred_init method must be called explicitly, once the missing attribute assignments have been made.

## Structure¶

In addition to its function, a Projection has two primary attributes: a sender and receiver. The types of State(s) that can be assigned to these, and the attributes of those States to which Projections of each type are assigned, are summarized in the following table, and described in greater detail in the subsections below. In addition to the State attributes to which different types of Projections are assigned (shown in the table), all of the Projections of a State are listed in its projections attribute.

Sender, Receiver and Attribute Assignments for Projection Types
MappingProjection OutputState (efferents) InputState (path_afferents)
LearningProjection LearningSignal (efferents) ParameterState (mod_afferents)
ControlProjection ControlSignal (efferents) ParameterState (mod_afferents)
GatingProjection GatingSignal (efferents) InputState or OutputState (mod_afferents)

### Sender¶

This must be an OutputState or a ModulatorySignal (a subclass of OutputState specialized for ModulatoryProjections). The Projection is assigned to the OutputState or ModulatorySignal’s efferents list and, for ModulatoryProjections, to the list of ModulatorySignals specific to the AdaptiveMechanism from which it projects. The OutputState or ModulatorySignal’s value is used as the variable for Projection’s function.

A sender can be specified as:

• an OutputState or ModulatorySignal, as appropriate for the Projection’s type, using any of the ways for specifying an OutputState.

If the sender is not specified and it can’t be determined from the context, or an OutputState specification is not associated with a Mechanism that can be determined from context, then the initialization of the Projection is deferred.

The receiver required by a Projection depends on its type, as listed below:

A MappingProjection (as a PathwayProjection) is assigned to the path_afferents attribute of its receiver. The ModulatoryProjections are assigned to the mod_afferents attribute of their receiver.

A receiver can be specified as:

• an existing State;
• an existing Mechanism or Projection; which of these is permissible, and how a state is assigned to it, is determined by the type of Projection — see subclasses for details).
• a specification dictionary (see subclasses for details).

### Weight and Exponent¶

Every Projection has a weight and exponent attribute. These are applied to its value before combining it with other Projections that project to the same States. If both are specified, the exponent is applied before the weight. These attributes determine both how the Projection’s value is combined with others to determine the variable of the State to which they project.

Note

The weight and exponent attributes of a Projection are not the same as a State’s weight and exponent attributes. Also, they are not normalized: their aggregate effects contribute to the magnitude of the variable to which they project.

### ParameterStates and Parameters¶

ParameterStates provide the value for each parameter of a Projection and its function. ParameterStates and their associated parameters are handled in the same way by Projections as they are for Mechanisms (see ParameterStates and Parameters for details). The ParameterStates for a Projection are listed in its parameter_states attribute.

## Execution¶

A Projection cannot be executed directly. It is executed when the State to which it projects (i.e., its receiver) is updated; that occurs when the State’s owner Mechanism is executed. When a Projection executes, it gets the value of its sender, assigns this as the variable of its function, calls the function, and provides the result as to its receiver. The function of a Projection converts the value received from its sender to a form suitable as input for its receiver.

class psyneulink.components.projections.projection.Projection_Base(receiver, sender=None, params=None, name=None, prefs=None)

Base class for all Projections.

Note

Projection is an abstract class and should NEVER be instantiated by a direct call to its constructor. It should be created by calling the constructor for a subclass or by using any of the other methods for specifying a Projection.

variable

value – input to Projection, received from OutputState.value of sender.

sender

State – State from which Projection receives its input (see Sender for additional information).

receiver

State – State to which Projection sends its output (see Receiver for additional information)

value

value – Output of Projection, transmitted as variable to InputState of receiver.

parameter_states

ContentAddressableList[str, ParameterState] – a list of the Projection’s ParameterStates, one for each of its specifiable parameters and those of its function (i.e., the ones for which there are arguments in their constructors). The value of the parameters of the Projection are also accessible as attributes of the Projection (using the name of the parameter); the function parameters are listed in the Projection’s function_params attribute, and as attributes of the Functions assigned to its function_object attribute.

parameter_states

ContentAddressableList[str, ParameterState] – a read-only list of the Projection’s ParameterStates, one for each of its configurable parameters, including those of its function. The value of the parameters of the Projection and its function are also accessible as (and can be modified using) attributes of the Projection, in the same manner as they can for a Mechanism).

weight

number – multiplies the value of the Projection after applying the exponent, and before combining with any other Projections that project to the same States to determine that State’s variable.

exponent

number – exponentiates the value of the Projection, before applying weight, and before combining it with any other Projections that project to the same States to determine that State’s variable.

name

str – the name of the Projection. If the Projection’s initialization has been deferred, it is assigned a temporary name (indicating its deferred initialization status) until initialization is completed, at which time it is assigned its designated name. If that is the name of an existing Projection, it is appended with an indexed suffix, incremented for each Projection with the same base name (see Naming). If the name is not specified in the name argument of its constructor, a default name is assigned by the subclass (see subclass for details)

prefs

PreferenceSet or specification dict – the PreferenceSet for the Projection; 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).