• Github
Table of Contents
0.19.1.0
  • Welcome to PsyNeuLink
  • Basics and Primer
  • Quick Reference
  • Core
  • Library
  • Contributors Guide
  • Docs >
  • Library >
  • Components >
  • Mechanisms >
  • Processing Mechanisms >
  • IntegratorMechanisms >
  • ExternalMemoryMechanism
Shortcuts

ExternalMemoryMechanism¶

Subclass of EpisodicMemoryMechanism customized for EMComposition.

It is a field-local that uses MatrixMemory as its function, which supports only a single field of memory.

It has QUERY and COMBINED_SCORES InputPorts If it is constructed with FieldType.KEY:

  • it has RETRIEVED, SCORES and NORMS OutputPorts

  • SCORES and NORMS are used by combined_scores_node of emcomposition

    to combine then for retrieval (SCORES) and storage (NORMS)

  • function computes match scores between query and each entry in memory, reported in its SCORES OutputPort

If it is constructed with FieldType.VALUE:
  • it has only RETRIEVED and NORMS OutputPorts - no SCORES OutputPort, since by definition those are not computed for VALUES - has NORMS, since the value is included in the NORMS calculation jused to determine where to store

  • it does not compute match scores, but does report retrieved value based on COMBINED_SCORES input

It has an access_condition, assigned by emcomposition, that is used to determine when to retrieve and when to store:
  1. if access_condition is NOT satisfied: - _execute() is called with runtime_params[OPERATION: COMPUTE_SCORES]

  2. if access_condition is satisfied: - _execute() is called with runtime_params[OPERATION: ACCESS_MEMORY]

  • it is assumed that (a) always occurs before (b) in execution of emcompostion2

EM2 BREADCRUMB: GET DOCSTRING FROM COMBINATION OF EpisodicMemoryMechanism and EMStorageMechanism

IMPLEMENTATION NOTE:

emcompositon2 uses one ExternalMemoryMechanism per memory field instead of using EMStorageMechanism to update MappingProjection matrices.

class psyneulink.library.components.mechanisms.processing.integrator.externalmemorymechanism.ExternalMemoryMechanism(field_type, field_shape, field_memory, decay_rate=None, storage_prob=1.0, normalize_memories=True, scores_metric=None, params=None, name=None, prefs=None, **kwargs)¶

EM2 BREADCRUMB: REVISE THE FOLLOWING TO BE CONSISTENT WITH UPDATES IN MODULE DOCSTRING

A field-local EpisodicMemoryMechanism used by EMComposition, that:
  • is restricted to use of MatrixMemory as it function

  • uses access_condition to enforce that storage occurs after retrieval

  • has two InputPorts: - QUERY used to compute field-specific SCORES - COMBINED_SCORES used for retrieval from memory

  • has two OutputPorts: - SCORES reports field-specific match weights for QUERY against memory - RETRIEVED used to report COMBINED_SCORES-weighted retrieval from memory

MatrixMemory:
  • supports only a single field

  • is used to store the Mechanisms’ memory

  • returns scores for match of query to each entry in memory

  • takes scores argument (received on Mechanism’s COMBINED_SCORES InputPort) as argument used for retrieval

IMPLEMENTATION NOTE: This is in distinction to the original EMComposition_Proj, in which each field’s memory

was stored in Projection matrices managed by EMStorageMechanism.

Ports¶

input_port[QUERY]

Current vector for this field. Used for score computation and storage.

output_port[SCORES]

Match-weight vector between QUERY and every row in field_memory, passed to ContentAddressableField Function for retrieval

input_port[COMBINED_SCORES]

Combined retrieval weights, usually the softmax-normalized aggregate of all key-field SCORES.

output_port[RETRIEVED]

Dot product of COMBINED_SCORES with field_memory.

_handle_default_variable(default_variable=None, input_shapes=None, input_ports=None, function=None, params=None)¶
Override to initialize or validate default_variable based on _memory_init or function.memory
  • if memory argument for Mechanism is specified and default_variable is not, use former to specify latter;

  • if both are specified, validate that they are the same shape;

  • if function.memory is specified and default_variable is not, use former to specify latter;

  • if both are specified, validate that they are the same shape;

  • if default_variable is specified and neither memory arg of Mechanism nor function.memory is specified,

    use default_variable to specify function.memory.

Note: handling this here insures that input_ports are specified/validated using correct default_variable

_instantiate_input_ports(context=None)¶

Override to assign default names to input_ports

_validate_variable(variable, context=None)¶

Convert variable to 2D np.array: one 1D value for each InputPort

# VARIABLE SPECIFICATION: ENCODING: # Simple value variable: 0 -> [array([0])] # Single port array (vector) variable: [0, 1] -> [array([0, 1]) # Multiple port variables, each with a single value variable: [[0], [0]] -> [array[0], array[0]]

Parameters:
  • variable

  • context

Returns:

parameters = <psyneulink.library.components.mechanisms.processing.integrator.externalmemorymechanism.ExternalMemoryMechanism.Parameters object> : ( access_condition = Parameter( _user_specified=False bool_as_number=True default_value=None delivery_condition=<LogCondition.OFF: 0> dependencies=None fallback_value=<class 'psyneulink.core.globals.parameters.ParameterNoValueError'> function_arg=True history={} history_max_length=1 history_min_length=0 loggable=False mdf_name=None name='access_condition' parse_spec=False pnl_internal=False port=None reference=False specify_none=False stateful=False structural=False user=True values={} ), decay_rate = FunctionParameter( _user_specified=False attribute_name='function' bool_as_number=True default_value=array(0.) delivery_condition=<LogCondition.OFF: 0> dependencies=None fallback_value=<class 'psyneulink.core.globals.parameters.ParameterNoValueError'> function_arg=True function_name='function' function_parameter_name='decay_rate' getter=<function _SharedParameter_default_getter> history={} history_max_length=1 history_min_length=0 loggable=True mdf_name=None modulable=True modulation_combination_function=None name='decay_rate' parse_spec=False pnl_internal=False port=None primary=True reference=False setter=<function _SharedParameter_default_setter> shared_parameter_name='decay_rate' specify_none=False stateful=True structural=False user=True values={} ), execute_until_finished = Parameter( _user_specified=False bool_as_number=True default_value=True delivery_condition=<LogCondition.OFF: 0> dependencies=None fallback_value=<class 'psyneulink.core.globals.parameters.ParameterNoValueError'> function_arg=True history={} history_max_length=1 history_min_length=0 loggable=True mdf_name=None name='execute_until_finished' parse_spec=False pnl_internal=True port=None reference=False specify_none=False stateful=True structural=False user=True values={} ), execution_count = Parameter( _user_specified=False bool_as_number=True default_value=array(0) delivery_condition=<LogCondition.OFF: 0> dependencies=None fallback_value='default' function_arg=True history={} history_max_length=1 history_min_length=0 loggable=False mdf_name=None name='execution_count' parse_spec=False pnl_internal=True port=None read_only=True reference=False specify_none=False stateful=False structural=False user=True values={} ), function = Parameter( _user_specified=False bool_as_number=True default_value=<class 'psyneulink.core.components.functions.nonstateful.transformfunctions.MatrixMemory'> delivery_condition=<LogCondition.OFF: 0> dependencies=None fallback_value=<class 'psyneulink.core.globals.parameters.ParameterNoValueError'> function_arg=True history={} history_max_length=1 history_min_length=0 loggable=False mdf_name=None name='function' parse_spec=False pnl_internal=False port=None reference=False specify_none=False stateful=False structural=False user=True values={} ), has_initializers = Parameter( _user_specified=False bool_as_number=True default_value=False delivery_condition=<LogCondition.OFF: 0> dependencies=None fallback_value=<class 'psyneulink.core.globals.parameters.ParameterNoValueError'> function_arg=True history={} history_max_length=1 history_min_length=0 loggable=True mdf_name=None name='has_initializers' parse_spec=False pnl_internal=True port=None reference=False setter=<function _has_initializers_setter> specify_none=False stateful=True structural=False user=True values={} ), input_labels_dict = Parameter( _user_specified=False bool_as_number=True default_value={} delivery_condition=<LogCondition.OFF: 0> dependencies=None fallback_value=<class 'psyneulink.core.globals.parameters.ParameterNoValueError'> function_arg=True history={} history_max_length=1 history_min_length=0 loggable=False mdf_name=None name='input_labels_dict' parse_spec=False pnl_internal=True port=None reference=False specify_none=False stateful=False structural=False user=True values={} ), input_ports = Parameter( _user_specified=False bool_as_number=True default_value=None delivery_condition=<LogCondition.OFF: 0> dependencies=None fallback_value=<class 'psyneulink.core.globals.parameters.ParameterNoValueError'> function_arg=True history={} history_max_length=1 history_min_length=0 loggable=False mdf_name=None name='input_ports' parse_spec=False pnl_internal=False port=None read_only=True reference=False specify_none=False stateful=False structural=True user=True values={} ), is_finished_flag = Parameter( _user_specified=False bool_as_number=True default_value=True delivery_condition=<LogCondition.OFF: 0> dependencies=None fallback_value=<class 'psyneulink.core.globals.parameters.ParameterNoValueError'> function_arg=True history={} history_max_length=1 history_min_length=0 loggable=False mdf_name=None name='is_finished_flag' parse_spec=False pnl_internal=False port=None reference=False specify_none=False stateful=True structural=False user=True values={} ), max_executions_before_finished = Parameter( _user_specified=False bool_as_number=True default_value=array(1000) delivery_condition=<LogCondition.OFF: 0> dependencies=None fallback_value=<class 'psyneulink.core.globals.parameters.ParameterNoValueError'> function_arg=True history={} history_max_length=1 history_min_length=0 loggable=True mdf_name=None name='max_executions_before_finished' parse_spec=False pnl_internal=True port=None reference=False specify_none=False stateful=True structural=False user=True values={} ), memory = FunctionParameter( _user_specified=False attribute_name='function' bool_as_number=True default_value=None delivery_condition=<LogCondition.OFF: 0> dependencies=None fallback_value=<class 'psyneulink.core.globals.parameters.ParameterNoValueError'> function_arg=True function_name='function' function_parameter_name='initializer' getter=<function _SharedParameter_default_getter> history={} history_max_length=1 history_min_length=0 loggable=True mdf_name=None name='memory' parse_spec=False pnl_internal=False port=None primary=True reference=False setter=<function _SharedParameter_default_setter> shared_parameter_name='initializer' specify_none=False stateful=True structural=False user=True values={} ), normalize_memories = Parameter( _user_specified=False bool_as_number=True default_value=True delivery_condition=<LogCondition.OFF: 0> dependencies=None fallback_value=<class 'psyneulink.core.globals.parameters.ParameterNoValueError'> function_arg=True history={} history_max_length=1 history_min_length=0 loggable=True mdf_name=None name='normalize_memories' parse_spec=False pnl_internal=False port=None reference=False specify_none=False stateful=True structural=False user=True values={} ), num_executions = Parameter( _user_specified=False bool_as_number=True default_value=Time(run: 0, trial: 0, pass: 0, time_step: 0) delivery_condition=<LogCondition.OFF: 0> dependencies=None fallback_value='default' function_arg=True history={} history_max_length=1 history_min_length=0 loggable=False mdf_name=None name='num_executions' parse_spec=False pnl_internal=True port=None read_only=True reference=False specify_none=False stateful=True structural=False user=True values={} ), num_executions_before_finished = Parameter( _user_specified=False bool_as_number=True default_value=array(0) delivery_condition=<LogCondition.OFF: 0> dependencies=None fallback_value=<class 'psyneulink.core.globals.parameters.ParameterNoValueError'> function_arg=True history={} history_max_length=1 history_min_length=0 loggable=True mdf_name=None name='num_executions_before_finished' parse_spec=False pnl_internal=True port=None read_only=True reference=False specify_none=False stateful=True structural=False user=True values={} ), output_labels_dict = Parameter( _user_specified=False bool_as_number=True default_value={} delivery_condition=<LogCondition.OFF: 0> dependencies=None fallback_value=<class 'psyneulink.core.globals.parameters.ParameterNoValueError'> function_arg=True history={} history_max_length=1 history_min_length=0 loggable=False mdf_name=None name='output_labels_dict' parse_spec=False pnl_internal=True port=None reference=False specify_none=False stateful=False structural=False user=True values={} ), output_ports = Parameter( _user_specified=False bool_as_number=True default_value=None delivery_condition=<LogCondition.OFF: 0> dependencies=None fallback_value=<class 'psyneulink.core.globals.parameters.ParameterNoValueError'> function_arg=True history={} history_max_length=1 history_min_length=0 loggable=False mdf_name=None name='output_ports' parse_spec=False pnl_internal=False port=None read_only=True reference=False specify_none=False stateful=False structural=True user=True values={} ), scores_metric = FunctionParameter( _user_specified=False attribute_name='function' bool_as_number=True default_value='dot_product' delivery_condition=<LogCondition.OFF: 0> dependencies=None fallback_value=<class 'psyneulink.core.globals.parameters.ParameterNoValueError'> function_arg=True function_name='function' function_parameter_name='scores_metric' getter=<function _SharedParameter_default_getter> history={} history_max_length=1 history_min_length=0 loggable=True mdf_name=None name='scores_metric' parse_spec=False pnl_internal=False port=None primary=True reference=False setter=<function _SharedParameter_default_setter> shared_parameter_name='scores_metric' specify_none=False stateful=False structural=False user=True values={} ), storage_prob = FunctionParameter( _user_specified=False attribute_name='function' bool_as_number=True default_value=array(1.) delivery_condition=<LogCondition.OFF: 0> dependencies=None fallback_value=<class 'psyneulink.core.globals.parameters.ParameterNoValueError'> function_arg=True function_name='function' function_parameter_name='storage_prob' getter=<function _SharedParameter_default_getter> history={} history_max_length=1 history_min_length=0 loggable=True mdf_name=None modulable=True modulation_combination_function=None name='storage_prob' parse_spec=False pnl_internal=False port=None primary=True reference=False setter=<function _SharedParameter_default_setter> shared_parameter_name='storage_prob' specify_none=False stateful=True structural=False user=True values={} ), value = Parameter( _user_specified=False bool_as_number=True default_value=array([[0]]) delivery_condition=<LogCondition.OFF: 0> dependencies=None fallback_value=<class 'psyneulink.core.globals.parameters.ParameterNoValueError'> function_arg=True history={} history_max_length=1 history_min_length=0 loggable=True mdf_name=None name='value' parse_spec=False pnl_internal=True port=None read_only=True reference=False specify_none=False stateful=True structural=False user=True values={} ), variable = Parameter( _user_specified=False bool_as_number=True constructor_argument='default_variable' default_value=array([[0, 0]]) delivery_condition=<LogCondition.OFF: 0> dependencies=None fallback_value=<class 'psyneulink.core.globals.parameters.ParameterNoValueError'> function_arg=True history={} history_max_length=1 history_min_length=0 loggable=True mdf_name=None name='variable' parse_spec=False pnl_internal=True port=None reference=False specify_none=False stateful=True structural=False user=True values={} ), )¶
exception psyneulink.library.components.mechanisms.processing.integrator.externalmemorymechanism.ExternalMemoryMechanismError(message, component=None)¶
Next Previous

© Copyright 2016, Jonathan D. Cohen.

Built with Sphinx using a theme provided by Read the Docs.
  • ExternalMemoryMechanism
    • ExternalMemoryMechanism
      • ExternalMemoryMechanism._handle_default_variable()
      • ExternalMemoryMechanism._instantiate_input_ports()
      • ExternalMemoryMechanism._validate_variable()
      • ExternalMemoryMechanism.parameters
    • ExternalMemoryMechanismError
  • Github