How to use the psyneulink.RecurrentTransferMechanism function in psyneulink

To help you get started, we’ve selected a few psyneulink examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PrincetonUniversity / PsyNeuLink / tests / misc / test_parameters.py View on Github external
import copy
import numpy as np
import psyneulink as pnl
import pytest


# (ancestor, child, should_override)
ancestor_child_data = [
    (pnl.Component, pnl.TransferMechanism, False),
    (pnl.Component, pnl.OutputPort, False),
    (pnl.Component, pnl.InputPort, True),
    (pnl.Component, pnl.SimpleIntegrator, False),
    (pnl.Function_Base, pnl.SimpleIntegrator, True),
    (pnl.TransferMechanism, pnl.RecurrentTransferMechanism, True)
]

# (obj, param_name, alias_name)
param_alias_data = [
    (pnl.Linear, 'slope', 'multiplicative_param'),
    (pnl.Linear, 'intercept', 'additive_param'),
    (pnl.ControlMechanism, 'value', 'control_allocation'),
]


@pytest.fixture(scope='function')
def reset_variable(*args):
    yield
    # pytest cannot provide the exact parametrized arguments to fixtures
    # so just reset all of the possibilities
    # this must be used when altering class level defaults
github PrincetonUniversity / PsyNeuLink / tests / models / test_botvinick.py View on Github external
task_input_layer = pnl.TransferMechanism(size=2,
                                             function=psyneulink.core.components.Linear,
                                             name='TASK_INPUT')

    #   Task layer, tasks: ('name the color', 'read the word')
    task_layer = pnl.RecurrentTransferMechanism(size=2,
                                                function=psyneulink.core.components.Logistic,
                                                hetero=-2,
                                                integrator_mode=True,
                                                integration_rate=0.01,
                                                name='TASK_LAYER')

    # Hidden layer
    # colors: ('red','green', 'neutral') words: ('RED','GREEN', 'NEUTRAL')
    colors_hidden_layer = pnl.RecurrentTransferMechanism(size=3,
                                                         function=psyneulink.core.components.Logistic(x_0=4.0),  # bias 4.0 is -4.0 in the paper see Docs for description
                                                         integrator_mode=True,
                                                         hetero=-2,
                                                         integration_rate=0.01,  # cohen-huston text says 0.01
                                                         name='COLORS_HIDDEN')

    words_hidden_layer = pnl.RecurrentTransferMechanism(size=3,
                                                        function=psyneulink.core.components.Logistic(x_0=4.0),
                                                        integrator_mode=True,
                                                        hetero=-2,
                                                        integration_rate=0.01,
                                                        name='WORDS_HIDDEN')

    #   Response layer, responses: ('red', 'green')
    response_layer = pnl.RecurrentTransferMechanism(size=2,
                                                    function=psyneulink.core.components.Logistic,
github PrincetonUniversity / PsyNeuLink / tests / composition / test_models.py View on Github external
# Create color feature layer, word feature layer, task demand layer and response layer
        color_feature_layer = pnl.RecurrentTransferMechanism(
            size=2,  # Define unit size
            function=psyneulink.core.components.functions.transferfunctions.Logistic(gain=4, x_0=1),  # to 4 & bias to 1
            integrator_mode=True,  # Set IntegratorFunction mode to True
            integration_rate=Lambda,  # smoothing factor ==  integration rate
            hetero=inhibition,  # Inhibition among units within a layer
            output_states=[{  # Create new output state by applying
                pnl.NAME: 'SPECIAL_LOGISTIC',  # the "my_special_Logistic" function
                pnl.VARIABLE: (pnl.OWNER_VALUE, 0),
                pnl.FUNCTION: my_special_Logistic
            }],
            name='COLOR_LAYER')

        # The word_feature_layer is set up as the color_feature_layer
        word_feature_layer = pnl.RecurrentTransferMechanism(
            size=2,  # Define unit size
            function=psyneulink.core.components.functions.transferfunctions.Logistic(gain=4, x_0=1),  # to 4 & bias to 1
            integrator_mode=True,  # Set IntegratorFunction mode to True
            integration_rate=Lambda,  # smoothing factor ==  integration rate
            hetero=inhibition,  # Inhibition among units within a layer
            output_states=[{  # Create new output state by applying
                pnl.NAME: 'SPECIAL_LOGISTIC',  # the "my_special_Logistic" function
                pnl.VARIABLE: (pnl.OWNER_VALUE, 0),
                pnl.FUNCTION: my_special_Logistic
            }],
            name='WORD_LAYER')

        # The response_layer is set up as the color_feature_layer & the word_feature_layer
        response_layer = pnl.RecurrentTransferMechanism(
            size=2,  # Define unit size
            function=psyneulink.core.components.functions.transferfunctions.Logistic(gain=4, x_0=1),  # to 4 & bias to 1
github PrincetonUniversity / PsyNeuLink / tests / composition / test_models.py View on Github external
function=psyneulink.core.components.functions.transferfunctions.Linear,
            name='TASK_INPUT'
        )

        #   Task layer, tasks: ('name the color', 'read the word')
        task_layer = pnl.RecurrentTransferMechanism(
            size=2,
            function=psyneulink.core.components.functions.transferfunctions.Logistic(),
            hetero=-2,
            integrator_mode=True,
            integration_rate=0.1,
            name='TASK'
        )

        #   Hidden layer units, colors: ('red','green') words: ('RED','GREEN')
        colors_hidden_layer = pnl.RecurrentTransferMechanism(
            size=3,
            function=psyneulink.core.components.functions.transferfunctions.Logistic(x_0=4.0),
            integrator_mode=True,
            hetero=-2.0,
            # noise=pnl.NormalDist(mean=0.0, standard_deviation=.0).function,
            integration_rate=0.1,  # cohen-huston text says 0.01
            name='COLORS HIDDEN'
        )

        words_hidden_layer = pnl.RecurrentTransferMechanism(
            size=3,
            function=psyneulink.core.components.functions.transferfunctions.Logistic(x_0=4.0),
            hetero=-2,
            integrator_mode=True,
            # noise=pnl.NormalDist(mean=0.0, standard_deviation=.05).function,
            integration_rate=0.1,
github PrincetonUniversity / PsyNeuLink / Scripts / Markus_conflict_monitoring_bidirectional.py View on Github external
#   Linear input units, colors: ('red', 'green'), words: ('RED','GREEN')
colors_input_layer = pnl.TransferMechanism(size=3,
                                           function=pnl.Linear,
                                           name='COLORS_INPUT')

words_input_layer = pnl.TransferMechanism(size=3,
                                          function=pnl.Linear,
                                          name='WORDS_INPUT')

task_input_layer = pnl.TransferMechanism(size=2,
                                          function=pnl.Linear,
                                          name='TASK_INPUT')

#   Task layer, tasks: ('name the color', 'read the word')
#change from Linear to Logistic with control on. Linear for saniti checks
task_layer = pnl.RecurrentTransferMechanism(default_variable=np.array([[0, 0]]),
                                            function=pnl.Logistic(),
                                            size=2,
                                            auto=-2,
                                            smoothing_factor=0.1,
                                   # function=pnl.Logistic(gain=(1.0, pnl.ControlProjection())),#receiver= response_layer.output_states[1],
#'DECISION_ENERGY'))
                                       #modulation=pnl.ModulationParam.OVERRIDE,#what to implement here
                                   name='TASK')


#   Hidden layer units, colors: ('red','green') words: ('RED','GREEN')
colors_hidden_layer = pnl.RecurrentTransferMechanism(#default_variable=np.array([[0, 0, 0]]),
                                                     size=3,
                                            function=pnl.Logistic(gain=1.0, bias=4.0), # bias 4.0 is -4.0 in the paper see Docs for description
                                            integrator_mode=True,
                                                     auto=-2,
github PrincetonUniversity / PsyNeuLink / Scripts / Models (Under Development) / stabilityFlexibilityFitting.py View on Github external
wa = 0.2



# first element is color task attendance, second element is motion task attendance
inputLayer = pnl.TransferMechanism(#default_variable=[[0.0, 0.0]],
                                   size=2,
                                   function=pnl.Linear(slope=1, intercept=0),
                                   output_states = [pnl.RESULT],
                                   name='Input')
inputLayer.set_log_conditions([pnl.RESULT])

# Recurrent Transfer Mechanism that models the recurrence in the activation between the two stimulus and action
# dimensions. Positive self excitation and negative opposite inhibition with an integrator rate = tau
# Modulated variable in simulations is the GAIN variable of this mechanism
activation = pnl.RecurrentTransferMechanism(default_variable=[[0.0, 0.0]],
                                            function=pnl.Logistic(gain=5),
                                            matrix=[[1.0, -1.0],
                                                    [-1.0, 1.0]],
                                            integrator_mode = True,
                                            integrator_function=pnl.AdaptiveIntegrator(rate=integrationConstant),
                                            initial_value=np.array([[0.0, 0.0]]),
                                            output_states = [pnl.RESULT],
                                            name = 'Activity')

activation.set_log_conditions([pnl.RESULT, "mod_gain"])


stimulusInfo = pnl.TransferMechanism(default_variable=[[0.0, 0.0]],
                                     size = 2,
                                     function = pnl.Linear(slope=1, intercept=0),
                                     output_states = [pnl.RESULT],
github PrincetonUniversity / PsyNeuLink / psyneulink / library / models / Kalanthroff_PCTC_2018.py View on Github external
size=2,                         # Define unit size
    function=psyneulink.core.components.functions.transferfunctions.Logistic(gain=4, x_0=1),           # to 4 & bias to 1
    integrator_mode=True,           # Set IntegratorFunction mode to True
    integration_rate=Lambda,        # smoothing factor ==  integration rate
    hetero=inhibition,              # Inhibition among units within a layer
    output_ports=[{           # Create new OutputPort by applying
        pnl.NAME: 'SPECIAL_LOGISTIC',        # the "my_special_Logistic" function
        pnl.VARIABLE: (pnl.OWNER_VALUE, 0),
        pnl.FUNCTION: my_special_Logistic
    }],
    name='RESPONSE_LAYER'
)

# The task_demand_layer is set up as the color_feature_layer but with a different python function on it's OutputPort
# and a differnet inhibition weight on the hetero
task_demand_layer = pnl.RecurrentTransferMechanism(
    size=2,                      # Define unit size
    function=psyneulink.core.components.functions.transferfunctions.Logistic(gain=4, x_0=1),            # to 4 & bias to 1
    integrator_mode=True,   # Set IntegratorFunction mode to True
    integration_rate=Lambda,  # smoothing factor ==  integration rate
    hetero=inhibition_task,  # Inhibition among units within a layer
    output_ports=[               # Create new OutputPort by applying
        {
            pnl.NAME: 'SPECIAL_LOGISTIC',        # the "my_conflict_function" function
            pnl.VARIABLE: (pnl.OWNER_VALUE, 0),
            pnl.FUNCTION: my_special_Logistic
        },
        {
            pnl.NAME: 'CONFLICT',
            pnl.VARIABLE: (pnl.OWNER_VALUE, 0),
            pnl.FUNCTION: my_conflict_function
        }
github PrincetonUniversity / PsyNeuLink / branch / devel / _downloads / Botvinick_conflict_monitoring_model.py View on Github external
import psyneulink.core.components.functions.transferfunctions

colors_input_layer = pnl.TransferMechanism(size=3,
                                           function=psyneulink.core.components.functions.transferfunctions.Linear,
                                           name='COLORS_INPUT')

words_input_layer = pnl.TransferMechanism(size=3,
                                          function=psyneulink.core.components.functions.transferfunctions.Linear,
                                          name='WORDS_INPUT')

task_input_layer = pnl.TransferMechanism(size=2,
                                         function=psyneulink.core.components.functions.transferfunctions.Linear,
                                         name='TASK_INPUT')

#   Task layer, tasks: ('name the color', 'read the word')
task_layer = pnl.RecurrentTransferMechanism(size=2,
                                            function=psyneulink.core.components.functions.transferfunctions.Logistic(),
                                            hetero=-2,
                                            integrator_mode=True,
                                            integration_rate=0.01,
                                            name='TASK_LAYER')

# Hidden layer
# colors: ('red','green', 'neutral') words: ('RED','GREEN', 'NEUTRAL')
colors_hidden_layer = pnl.RecurrentTransferMechanism(size=3,
                                                     function=psyneulink.core.components.functions.transferfunctions
                                                     .Logistic(x_0=4.0),  # bias 4.0 is -4.0 in the paper see Docs for description
                                                     integrator_mode=True,
                                                     hetero=-2,
                                                     integration_rate=0.01,  # cohen-huston text says 0.01
                                                     name='COLORS_HIDDEN')
github PrincetonUniversity / PsyNeuLink / branch / devel / _downloads / Botvinick_conflict_monitoring_model.py View on Github external
function=psyneulink.core.components.functions.transferfunctions
                                                     .Logistic(x_0=4.0),  # bias 4.0 is -4.0 in the paper see Docs for description
                                                     integrator_mode=True,
                                                     hetero=-2,
                                                     integration_rate=0.01,  # cohen-huston text says 0.01
                                                     name='COLORS_HIDDEN')

words_hidden_layer = pnl.RecurrentTransferMechanism(size=3,
                                                    function=psyneulink.core.components.functions.transferfunctions.Logistic(x_0=4.0),
                                                    integrator_mode=True,
                                                    hetero=-2,
                                                    integration_rate=0.01,
                                                    name='WORDS_HIDDEN')

#   Response layer, responses: ('red', 'green')
response_layer = pnl.RecurrentTransferMechanism(size=2,
                                                function=psyneulink.core.components.functions.transferfunctions.Logistic(),
                                                hetero=-2.0,
                                                integrator_mode=True,
                                                integration_rate=0.01,
                                                output_states = [pnl.RECURRENT_OUTPUT.RESULT,
                                                                 {pnl.NAME: 'DECISION_ENERGY',
                                                                  pnl.VARIABLE: (pnl.OWNER_VALUE,0),
                                                                  pnl.FUNCTION: psyneulink.core.components.functions
                                                .objectivefunctions.Stability(
                                                                      default_variable = np.array([0.0, 0.0]),
                                                                      metric = pnl.ENERGY,
                                                                      matrix = np.array([[0.0, -4.0],
                                                                                        [-4.0, 0.0]]))}],
                                                name='RESPONSE', )

# Log ------------------------------------------------------------------------------------------------------------------
github PrincetonUniversity / PsyNeuLink / Scripts / Examples / Composition / Botvinick Model Composition.py View on Github external
function=pnl.Logistic(),
                                            hetero=-2,
                                            integrator_mode=True,
                                            integration_rate=0.01,
                                            name='TASK_LAYER')

# Hidden layer
# colors: ('red','green', 'neutral') words: ('RED','GREEN', 'NEUTRAL')
colors_hidden_layer = pnl.RecurrentTransferMechanism(size=3,
                                                     function=pnl.Logistic(x_0=4.0),  # bias 4.0 is -4.0 in the paper see Docs for description
                                                     integrator_mode=True,
                                                     hetero=-2,
                                                     integration_rate=0.01,  # cohen-huston text says 0.01
                                                     name='COLORS_HIDDEN')

words_hidden_layer = pnl.RecurrentTransferMechanism(size=3,
                                                    function=pnl.Logistic(x_0=4.0),
                                                    integrator_mode=True,
                                                    hetero=-2,
                                                    integration_rate=0.01,
                                                    name='WORDS_HIDDEN')

#   Response layer, responses: ('red', 'green')
response_layer = pnl.RecurrentTransferMechanism(size=2,
                                                function=pnl.Logistic(),
                                                hetero=-2.0,
                                                integrator_mode=True,
                                                integration_rate=0.01,
                                                output_ports = [pnl.RESULT,
                                                                 {pnl.NAME: 'DECISION_ENERGY',
                                                                  pnl.VARIABLE: (pnl.OWNER_VALUE,0),
                                                                  pnl.FUNCTION: pnl.Stability(