• Github
Table of Contents
0.13.0.0
  • Welcome to PsyNeuLink
  • Basics and Primer
  • Quick Reference
  • Core
  • Library
  • Contributors Guide
  • Docs >
  • LearningProjection
Shortcuts

LearningProjection¶

Contents¶

  • Overview

  • Creating a LearningProjection
    • Deferred Initialization

    • Sender

    • Function and learning_rate

    • Receiver

  • Structure

  • Execution

  • Class Reference

Overview¶

A LearningProjection is a type of ModulatoryProjection that projects from a LearningMechanism to the MATRIX ParameterPort of a MappingProjection. It takes the value of a LearningSignal of a LearningMechanism, and uses it to modify the value of the matrix parameter of that MappingProjection. All of the LearningProjections in a System, along with its other learning components, can be displayed using the Composition’s show_graph method with its show_learning argument assigned as True.

Creating a LearningProjection¶

A LearningProjection can be created using any of the standard ways to create a Projection, or by including it in a tuple that specifies the matrix parameter of a MappingProjection. LearningProjections are also created automatically, along with the other Components required for learning, when learning is specified for a Process or a System.

If a LearningProjection is created explicitly (using its constructor), and its receiver argument is not specified, its initialization is deferred. If it is included in the matrix specification for a MappingProjection, the MATRIX ParameterPort for the MappingProjection will be assigned as the LearningProjection’s receiver. If its sender argument is not specified, its assignment depends on the receiver. If the receiver belongs to a MappingProjection that projects between two Mechanisms that are both in the same Process or System, then the LearningProjection’s sender is assigned to a LearningSignal of the LearningMechanism for the MappingProjection. If there is none, it is created along with any other components needed to implement learning for the MappingProjection (see Learning Configurations). Otherwise, the LearningProjection’s initialization is deferred.

Deferred Initialization¶

When a LearningProjection is created, its full initialization is deferred until its sender and receiver have been fully specified. This allows a LearningProjection 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 LearningProjection to be operational, initialization must be completed by calling its deferred_init method. This is not necessary if the LearningProjection is included in a tuple specification for the matrix parameter of a MappingProjection, in which case deferred initialization is completed automatically when the LearningMechanism associated with that MappingProjection is created for the Process or System to which it belongs (see Creating a LearningMechanism).

Structure¶

Sender¶

The sender of a LearningProjection is a LearningSignal of a LearningMechanism, The value of the sender – a matrix of weight changes – is used by the LearningProjection as its variable; this is also assigned to its learning_signal attribute, and serves as the input to the LearningProjection’s function.

Function and learning_rate¶

The default function of a LearningProjection is an identity function (Linear with slope=1 and intercept=0). However, its result can be modified by the LearningProjection’s learning_rate parameter (specified in the learning_rate argument of its constructor). If specified, it is applied multiplicatively to the output of the LearningProjection’s function, and the result is assigned to the LearningProjection’s value and weight_change_matrix attributes. Thus, the LearningProjection’s learning_rate parameter can be used to modulate the learning_signal it receives, in addition to (and on top of) the effects of the learning_rate for the LearningMechanism from which it receives the learning_signal. Specification of the learning_rate for a LearningProjection supersedes any specification(s) of the learning_rate for any Process and/or System to which the Projection belongs (see learning_rate for additional details). However, its learning_rate can be specified by the LearningSignal that is its sender; that specification takes precedence over the direct specification of the learning_rate for the LearningProjection (i.e., in the learning_rate argument of its constructor, or by direct assignment of a value to the attribute). If a learning_rate is not specified for the LearningProjection, then the result of its function is assigned unmodified as the LearningProjection’s value (and weight_change_matrix attributes.

Weight and Exponent¶

Every LearningProjection has a weight and exponent attribute that are applied to its value before it is combined with other LearningProjections that modify the ParameterPort for the matrix parameter of the MappingProjection to which they project (see description under Projection for additional details).

Note

The weight and exponent attributes of a LearningProjection are not commonly used, and are implemented largely for generality and compatibility with other types of Projection. They are distinct from, and are applied in addition to the LearningProjection’s learning_rate attribute. As noted under Projection, they are not normalized and thus their effects aggregate if a ParameterPort receives one or more LearningProjections with non-default values of their weight and exponent attributes.

Receiver¶

The receiver of a LearningProject is the MATRIX ParameterPort of a MappingProjection, that uses the weight_change_matrix provided by the LearningProjection to modify the matrix parameter of the MappingProjection being learned.

Execution¶

A LearningProjection cannot be executed directly. It’s execution is determined by its learning_enabled attribute. If that is False`, it is never executed. If it is True or ONLINE, is executed when the MATRIX ParameterPort to which it projects is updated. This occurs when the learned_projection (the MappingProjection to which the MATRIX ParameterPort belongs) is updated. Note that these events occur only when the ProcessingMechanism that receives the learned_projection is executed (see Lazy Evaluation for an explanation of “lazy” updating). If learning_enabled is AFTER, then LearningProjection is executed at the end of the TRIAL of the Composition to which it belongs. When the LearningProjection is executed, its function gets the learning_signal from its sender and conveys that to its receiver, possibly modified by a learning_rate if that is specified for it or its sender (see above).

Note

The changes to the matrix parameter of a MappingProjection in response to the execution of a LearningProjection are not applied until the Mechanism that receives MappingProjection are next executed; see Lazy Evaluation for an explanation of “lazy” updating).

Class Reference¶

psyneulink.core.components.projections.modulatory.learningprojection.DefaultTrainingMechanism¶

alias of psyneulink.core.components.mechanisms.processing.objectivemechanism.ObjectiveMechanism

class psyneulink.core.components.projections.modulatory.learningprojection.LearningProjection(sender=None, receiver=None, error_function, learning_function, learning_rate=None, learning_enabled=None                  weight=None, exponent=None, params=None, name=None, prefs=None)¶

Subclass of ModulatoryProjection that modulates the value of a ParameterPort for the matrix parameter of a MappingProjection. See Projection for additional arguments and attributes.

Parameters
  • sender (Optional[LearningMechanism or LearningSignal]) – specifies the source of the learning_signal for the LearningProjection; if it is not specified, and cannot be inferred from context, initialization is deferred.

  • receiver (Optional[MappingProjection or ParameterPort for matrix parameter of one]) – specifies the MATRIX ParameterPort (or the MappingProjection that owns it) for the matrix of the learned_projection to be modified by the LearningProjection; if it is not specified, and cannot be inferred from context, initialization is deferred.

  • function (TransferFunction : default Linear(slope=1, intercept=0)) – specifies the function used to convert the learning_signal to the weight_change_matrix, prior to applying the learning_rate.

  • error_function (Optional[Function or function] : default LinearCombination(weights=[[-1], [1]])) – specifies a function to be used by the TARGET Mechanism to compute the error used for learning. Since the TARGET Mechanism is a ComparatorMechanism, its function must have a variable with two items, that receives its values from the SAMPLE and TARGET InputPorts of the ComparatorMechanism.

  • learning_function (Optional[LearningFunction or function] : default BackPropagation) –

    specifies a function to be used for learning by the LearningMechanism to which the LearningProjection’s sender belongs.

    Note

    the learning_function argument is implemented to preserve backward compatibility with previous versions; its use is not advised.

  • learning_rate (Optional[float or int]) – if specified, it is applied multiplicatively to the learning_signal received from the sender; specification of the learning_rate for a LearningProjection supersedes any specification(s) of the learning_rate for any Process and/or System to which the LearningProjection belongs, and is applied in addition to any effects of the learning_rate for the LearningMechanism from which the LearningProjection receives its learning_signal (see Function and learning_rate for additional details).

  • learning_enabled (Optional[bool or Enum[ONLINE|AFTER]] : default : None) – determines whether or when the value of the LearningProjection is used to modify the learned_projection when the latter is executed (see learning_enabled for additional details).

sender¶

source of learning_signal (see Sender for additional details).

Type

LearningSignal

receiver¶

MATRIX ParameterPort for the matrix parameter of the learned_projection (see Receiver for additional details).

Type

MATRIX ParameterPort of a MappingProjection

learned_projection¶

the MappingProjection to which LearningProjection’s receiver belongs.

Type

MappingProjection

variable¶

same as learning_signal.

Type

2d np.array

learning_enabled¶

determines whether or when the value of the LearningProjection is used to modify the learned_projection when the latter is executed; by default, its value is set to the value of the learning_enabled attribute of the LearningMechanism to which the LearningProjection’s sender belongs; however it can be overridden using the learning_enabled argument of the LearningProjection’s constructor and/or by assignment after it is constructed (see learning_enabled for additional details).

Type

bool or Enum[ONLINE|AFTER]

learning_signal¶

the value of the LearningProjection’s sender: a matrix of weight changes calculated by the LearningMechanism to which the sender belongs; rows correspond to the sender of the learned_projection, and columns to its receiver (i.e., the input and output of the learned_projection, respectively).

Type

2d np.array

function¶

assigns the learning_signal received from the sender to the LearningProjection’s value, possibly modified by its learning_rate; the default in an identity function.

Type

Function

learning_rate¶

determines the learning_rate for the LearningProjection. If specified, it is applied multiplicatively to the learning_signal; its specification may be superseded by the learning_rate of its sender (see Function and learning_rate for additional details);

Type

float or None

weight_change_matrix¶

output of the LearningProjection’s function, possibly modified by its learning_rate; reflects the matrix of weight changes to be made to the matrix parameter of the learned_projection (rows correspond to the sender of the learned_projection, columns to its receiver (i.e., the input and output of the learned_projection, respectively).

Type

2d np.array

value¶

same as weight_change_matrix.

Type

2d np.array

projection_sender¶

alias of psyneulink.core.components.mechanisms.modulatory.learning.learningmechanism.LearningMechanism

_validate_params(request_set, target_set=None, context=None)¶

Validate sender and receiver

Insure sender is a LearningMechanism or the OutputPort of one. Insure receiver is a MappingProjection or the matrix ParameterPort of one.

_instantiate_sender(sender, context=None)¶

Instantiate LearningMechanism

_instantiate_receiver(context=None)¶

Validate that receiver has been assigned and is compatible with the output of function

Set learning_enabled to value of receiver if it was not otherwise specified in the constructor

Notes: * _validate_params verifies that receiver is a parameterPort for the matrix parameter of a MappingProjection. * _super()._instantiate_receiver verifies that the projection has not already been assigned to the receiver.

_execute(variable, context=None, runtime_params=None)¶
Returns

(2D np.array) self.weight_change_matrix

exception psyneulink.core.components.projections.modulatory.learningprojection.LearningProjectionError(error_value)¶

© Copyright 2016, Jonathan D. Cohen.

Built with Sphinx using a theme provided by Read the Docs.
  • LearningProjection
    • Contents
    • Overview
    • Creating a LearningProjection
      • Deferred Initialization
    • Structure
      • Sender
      • Function and learning_rate
      • Weight and Exponent
      • Receiver
    • Execution
    • Class Reference
  • Github