• Github
Table of Contents
0.16.1.0
  • Welcome to PsyNeuLink
  • Basics and Primer
  • Quick Reference
  • Core
  • Library
  • Contributors Guide
  • Docs >
  • Library >
  • Components >
  • Mechanisms >
  • Modulatory Mechanisms >
  • Learning Mechanisms >
  • AutoAssociativeLearningMechanism
Shortcuts

AutoAssociativeLearningMechanism¶

Contents¶

  • Overview

  • Creating an AutoAssociativeLearningMechanism

  • Structure

  • Execution

  • Class Reference

Overview¶

An AutoAssociativeLearningMechanism is a subclass of LearningMechanism, modified for use with a RecurrentTransferMechanism to train its recurrent_projection.

Creating an AutoAssociativeLearningMechanism¶

An AutoAssociativeLearningMechanism can be created directly by calling its constructor, but most commonly it is created automatically when a RecurrentTransferMechanism is configured for learning, (identified in its activity_source attribute).

Structure¶

An AutoAssociativeLearningMechanism is identical to a LearningMechanism in all respects except the following:

  • it has only a single ACTIVATION_INPUT InputPort, that receives a MappingProjection from an OutputPort of the RecurrentTransferMechanism with which it is associated (identified by the activity_source);

  • it has a single LEARNING_SIGNAL OutputPort that sends a LearningProjection to the matrix parameter of an ‘AutoAssociativeProjection` (typically, the recurrent_projection of a RecurrentTransferMechanism), but not an ERROR_SIGNAL OutputPort.

  • it has no input_source, output_source, or error_source attributes; instead, it has a single activity_source attribute that identifies the source of the activity vector used by the Mechanism’s function.

  • its function takes as its variable a list or 1d np.array of numeric entries, corresponding in length to the AutoAssociativeLearningMechanism’s ACTIVATION_INPUT InputPort; and it returns a learning_signal (a weight change matrix assigned to the Mechanism’s LEARNING_SIGNAL OutputPort), but not necessarily an error_signal.

  • its learning_rate can be specified as a 1d or 2d array (or matrix) to scale the contribution made, respectively, by individual elements or connections among them, to the weight change matrix; as with a standard LearningMechanism, a scalar can also be specified to scale the entire weight change matrix (see learning_rate for additional details).

Execution¶

An AutoAssociativeLearningMechanism executes in the same manner as standard LearningMechanism, with two exceptions: * 1) its execution can be enabled or disabled by setting the learning_enabled

attribute of the RecurrentTransferMechanism with which it is associated (identified in its activity_source attribute).

  • 2) it is executed during the execution phase of the Composition’s execution. Note that this is different from the behavior of supervised learning algorithms (such as Reinforcement and BackPropagation), that are executed during the learning phase of a Composition’s execution

Class Reference¶

class psyneulink.library.components.mechanisms.modulatory.learning.autoassociativelearningmechanism.AutoAssociativeLearningMechanism(default_variable, input_shapes=None, function=None, learning_signals=None, modulation=None, learning_rate=None, params=None, name=None, prefs=None, **kwargs)¶

Implements a LearningMechanism that modifies the matrix parameter of an AutoAssociativeProjection (typically the recurrent_projection of a RecurrentTransferMechanism).

Parameters
  • variable (List or 2d np.array : default None) – it must have a single item that corresponds to the value required by the AutoAssociativeLearningMechanism’s function; it must each be compatible (in number and type) with the value of the Mechanism’s InputPort (see variable for additional details).

  • learning_signals (List[parameter of Projection, ParameterPort, Projection, tuple[str, Projection] or dict] : default None) – specifies the matrix to be learned (see learning_signals for details of specification).

  • function (LearningFunction or function : default Hebbian) – specifies the function used to calculate the AutoAssociativeLearningMechanism’s learning_signal attribute. It must take as its variable argument a list or 1d array of numeric values (the “activity vector”) and return a list, 2d np.array representing a square matrix with dimensions that equal the length of its variable (the “weight change matrix”).

  • learning_rate (float : default None) – specifies the learning rate for the AutoAssociativeLearningMechanism. (see learning_rate for details).

variable¶

has a single item, that serves as the template for the input required by the AutoAssociativeLearningMechanism’s function, corresponding to the value of the activity_source.

Type

2d np.array

activity_source¶

the OutputPort that is the sender of the AutoAssociativeProjection that the Mechanism trains.

Type

OutputPort

input_ports¶

has a single item, that contains the AutoAssociativeLearningMechanism’s single ACTIVATION_INPUT InputPort.

Type

ContentAddressableList[OutputPort]

primary_learned_projection¶

the Projection with the matrix parameter being trained by the AutoAssociativeLearningMechanism. It is always the first Projection listed in the AutoAssociativeLearningMechanism’s learned_projections attribute.

Type

AutoAssociativeProjection

learned_projections¶

all of the AutoAssociativeProjections modified by the AutoAssociativeLearningMechanism; the first item in the list is always the primary_learned_projection.

Type

List[MappingProjection]

function¶

the function used to calculate the learning_signal (assigned to the AutoAssociativeLearningMechanism’s LearningSignal(s)). It’s variable must be a list or 1d np.array of numeric entries, corresponding in length to the AutoAssociativeLearningMechanism’s ACTIVATION_INPUT (primary) InputPort.

Type

LearningFunction or function : default Hebbian

learning_rate¶

determines the learning rate used by the AutoAssociativeLearningMechanism’s function to scale the weight change matrix it returns. If it is a scalar, it is used to multiply the weight change matrix; if it is a 2d array, it is used to Hadamard (elementwise) multiply the weight matrix (allowing the contribution of individual connections to be scaled); if it is a 1d np.array, it is used to Hadamard (elementwise) multiply the input to the function (i.e., the value of the AutoAssociativeLearningMechanism’s ACTIVATION_INPUT InputPort, allowing the contribution of individual units to be scaled). If specified, the value supersedes the learning_rate assigned to any Composition to which the AutoAssociativeLearningMechanism belongs. If it is None, then the learning_rate specified for the System to which the AutoAssociativeLearningMechanism belongs belongs is used; and, if that is None, then the default_learning_rate for the function is used (see learning_rate for additional details).

Type

float, 1d or 2d np.array of numeric values : default None

learning_signal¶

the value returned by function, that specifies the changes to the weights of the matrix parameter for the AutoAssociativeLearningMechanism’s`learned_projections <AutoAssociativeLearningMechanism.learned_projections>`; It is assigned as the value of the AutoAssociativeLearningMechanism’s LearningSignal(s) and, in turn, its LearningProjection(s).

Type

2d ndarray or matrix of numeric values

learning_signals¶

list of all of the LearningSignals for the AutoAssociativeLearningMechanism, each of which sends one or more LearningProjections to the ParameterPort(s) for the matrix parameter of the AutoAssociativeProjection(s) trained by the AutoAssociativeLearningMechanism. Although in most instances an AutoAssociativeLearningMechanism is used to train a single AutoAssociativeProjection, like a standard LearningMechanism, it can be assigned additional LearningSignals and/or LearningProjections to train additional ones; in such cases, the value for all of the LearningSignals is the the same: the AutoAssociativeLearningMechanism’s learning_signal attribute, based on its activity_source. Since LearningSignals are OutputPorts, they are also listed in the AutoAssociativeLearningMechanism’s output_ports attribute.

Type

List[LearningSignal]

learning_projections¶

list of all of the LearningProjections <LearningProjection>` from the AutoAssociativeLearningMechanism, listed in the order of the LearningSignals to which they belong (that is, in the order they are listed in the learning_signals attribute).

Type

List[LearningProjection]

output_ports¶

list of the AutoAssociativeLearningMechanism’s OutputPorts, beginning with its learning_signals, and followed by any additional (user-specified) OutputPorts.

Type

ContentAddressableList[OutputPort]

output_values¶

the first item is the value of the LearningMechanism’s learning_signal, followed by the values of any additional (user-specified) OutputPorts.

Type

2d np.array

_parse_function_variable(variable, context=None)¶

Parses the variable passed in to a Component into a function_variable that can be used with the Function associated with this Component

_validate_variable(variable, context=None)¶

Validate that variable has only one item: activation_input.

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

Execute AutoAssociativeLearningMechanism. function and return learning_signal

Returns

(2D np.array) self.learning_signal

_update_output_ports(runtime_params=None, context=None)¶

Update the weights for the AutoAssociativeProjection for which this is the AutoAssociativeLearningMechanism

Must do this here, so it occurs after LearningMechanism’s OutputPort has been updated. This insures that weights are updated within the same trial in which they have been learned

exception psyneulink.library.components.mechanisms.modulatory.learning.autoassociativelearningmechanism.AutoAssociativeLearningMechanismError(message, component=None)¶
psyneulink.library.components.mechanisms.modulatory.learning.autoassociativelearningmechanism.DefaultTrainingMechanism¶

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

Next Previous

© Copyright 2016, Jonathan D. Cohen.

Built with Sphinx using a theme provided by Read the Docs.
  • AutoAssociativeLearningMechanism
    • Contents
    • Overview
    • Creating an AutoAssociativeLearningMechanism
    • Structure
    • Execution
    • Class Reference
  • Github