How to use the psyneulink.core.components.functions.transferfunctions.Logistic 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 / mechanisms / test_transfer_mechanism.py View on Github external
def test_termination_measures(self):
        stim_input = ProcessingMechanism(size=2, name='Stim Input')
        stim_percept = TransferMechanism(name='Stimulus', size=2, function=Logistic)
        instruction_input = ProcessingMechanism(size=2, function=Linear(slope=10))
        attention = LCAMechanism(name='Attention', size=2, function=Logistic,
                                     leak=8, competition=8, self_excitation=0, noise=0, time_step_size=.1,
                                     termination_threshold=3,
                                     termination_measure = TimeScale.TRIAL)
        decision = TransferMechanism(name='Decision', size=2,
                                         integrator_mode=True,
                                         execute_until_finished=False,
                                         termination_threshold=0.65,
                                         termination_measure=max,
                                         termination_comparison_op=GREATER_THAN)
        response = ProcessingMechanism(size=2, name='Response')

        comp = Composition()
        comp.add_linear_processing_pathway([stim_input, [[1,-1],[-1,1]], stim_percept, decision, response])
        comp.add_linear_processing_pathway([instruction_input, attention, stim_percept])
github PrincetonUniversity / PsyNeuLink / tests / no-learning / test_stroop_no_learning.py View on Github external
name='WORDS_INPUT')

        #   Task layer, tasks: ('name the color', 'read the word')
        task_layer = pnl.TransferMechanism(size=2,
                                           function=psyneulink.core.components.functions.transferfunctions.Linear,
                                           name='TASK')

        #   HIDDEN LAYER UNITS

        #   colors_hidden: ('red','green')
        #   Logistic activation function, Gain = 1.0, Bias = -4.0 (in PNL bias is subtracted so enter +4.0 to get negative bias)
        #   randomly distributed noise to the net input
        #   time averaging = integration_rate = 0.1
        unit_noise = 0.005
        colors_hidden_layer = pnl.TransferMechanism(size=2,
                                                    function=psyneulink.core.components.functions.transferfunctions
                                                    .Logistic(gain=1.0, x_0=4.0),
                                                    # should be able to get same result with offset = -4.0
                                                    integrator_mode=True,
                                                    noise=psyneulink.core.components.functions.distributionfunctions
                                                    .NormalDist(mean=0, standard_deviation=unit_noise).function,
                                                    integration_rate=0.1,
                                                    name='COLORS HIDDEN')
        #    words_hidden: ('RED','GREEN')
        words_hidden_layer = pnl.TransferMechanism(size=2,
                                                   function=pnl.Logistic(gain=1.0, x_0=4.0),
                                                   integrator_mode=True,
                                                   noise=pnl.NormalDist(mean=0,
                                                                        standard_deviation=unit_noise).function,
                                                   integration_rate=0.1,
                                                   name='WORDS HIDDEN')
github PrincetonUniversity / PsyNeuLink / tests / composition / test_autodiffcomposition.py View on Github external
def test_param_init_from_pnl(self):

        # create xor model mechanisms and projections
        xor_in = TransferMechanism(name='xor_in',
                                   default_variable=np.zeros(2))

        xor_hid = TransferMechanism(name='xor_hid',
                                    default_variable=np.zeros(10),
                                    function=Logistic())

        xor_out = TransferMechanism(name='xor_out',
                                    default_variable=np.zeros(1),
                                    function=Logistic())

        hid_map = MappingProjection(matrix=np.random.rand(2,10))
        out_map = MappingProjection(matrix=np.random.rand(10,1))

        # put the mechanisms and projections together in an autodiff composition (AC)
        xor = AutodiffComposition(param_init_from_pnl=True)

        xor.add_node(xor_in)
        xor.add_node(xor_hid)
        xor.add_node(xor_out)

        xor.add_projection(sender=xor_in, projection=hid_map, receiver=xor_hid)
github PrincetonUniversity / PsyNeuLink / tests / composition / test_autodiffcomposition.py View on Github external
wih = np.random.rand(D_i, D_h) * 0.02 - 0.01
        wch = np.random.rand(D_c, D_h) * 0.02 - 0.01
        wco = np.random.rand(D_c, D_o) * 0.02 - 0.01
        who = np.random.rand(D_h, D_o) * 0.02 - 0.01

        patience = 10
        min_delt = 0.00001
        learning_rate = 100

        il = TransferMechanism(size=D_i, name='input')
        cl = TransferMechanism(size=D_c, name='control')
        hl = TransferMechanism(size=D_h, name='hidden',
                               function=Logistic(bias=-2))
        ol = TransferMechanism(size=D_o, name='output',
                               function=Logistic(bias=-2))

        input_set = {
            'inputs': {
                il: iSs,
                cl: cSs
            },
            'targets': {
                ol: oSs
            }
        }

        pih = MappingProjection(matrix=wih)
        pch = MappingProjection(matrix=wch)
        pco = MappingProjection(matrix=wco)
        pho = MappingProjection(matrix=who)
github PrincetonUniversity / PsyNeuLink / tests / composition / test_autodiffcomposition.py View on Github external
def test_xor_training_correctness(self, eps, calls, opt, from_pnl_or_no,mode):
        xor_in = TransferMechanism(name='xor_in',
                                   default_variable=np.zeros(2))

        xor_hid = TransferMechanism(name='xor_hid',
                                    default_variable=np.zeros(10),
                                    function=Logistic())

        xor_out = TransferMechanism(name='xor_out',
                                    default_variable=np.zeros(1),
                                    function=Logistic())

        hid_map = MappingProjection(matrix=np.random.rand(2,10), sender=xor_in, receiver=xor_hid)
        out_map = MappingProjection(matrix=np.random.rand(10,1))

        xor = AutodiffComposition(param_init_from_pnl=from_pnl_or_no,
                                  optimizer_type=opt,
                                  learning_rate=0.1)

        xor.add_node(xor_in)
        xor.add_node(xor_hid)
        xor.add_node(xor_out)
github PrincetonUniversity / PsyNeuLink / tests / learning / test_multilayer.py View on Github external
def test_multilayer():
    Input_Layer = TransferMechanism(
        name='Input Layer',
        function=Logistic,
        default_variable=np.zeros((2,)),
    )

    Hidden_Layer_1 = TransferMechanism(
        name='Hidden Layer_1',
        function=Logistic(),
        # default_variable=np.zeros((5,)),
        size=5
    )

    Hidden_Layer_2 = TransferMechanism(
        name='Hidden Layer_2',
        function=Logistic(),
        default_variable=[0, 0, 0, 0],
    )
github PrincetonUniversity / PsyNeuLink / Scripts / Examples / Mixed-NN-and-DDM.py View on Github external
import numpy as np
import psyneulink as pnl
import psyneulink.core.components.functions.distributionfunctions
import psyneulink.core.components.functions.transferfunctions

myInputLayer = pnl.TransferMechanism(
    name='Input Layer',
    function=psyneulink.core.components.functions.transferfunctions.Linear(),
    default_variable=[0, 0]
)

myHiddenLayer = pnl.TransferMechanism(
    name='Hidden Layer 1',
    function=psyneulink.core.components.functions.transferfunctions.Logistic(gain=1.0, x_0=0),
    default_variable=np.zeros((5,))
)

myDDM = pnl.DDM(
    name='My_DDM',
    function=psyneulink.core.components.functions.distributionfunctions.DriftDiffusionAnalytical(
        drift_rate=0.5,
        threshold=1,
        starting_point=0.0
    )
)

myProcess = pnl.Process(
    name='Neural Network DDM Process',
    default_variable=[0, 0],
    pathway=[
github PrincetonUniversity / PsyNeuLink / Scripts / Examples / System / Lena Rumelhart script.py View on Github external
nouns_in = pnl.TransferMechanism(name="nouns_input",
                                 default_variable=np.zeros(c_1)
                                )

rels_in = pnl.TransferMechanism(name="rels_input",
                                default_variable=np.zeros(c_2)
                               )

h1 = pnl.TransferMechanism(name="hidden_nouns",
                           size=9,
                           function=psyneulink.core.components.functions.transferfunctions.Logistic()
                            )

h2 = pnl.TransferMechanism(name="hidden_mixed",
                           size=16,
                           function=psyneulink.core.components.functions.transferfunctions.Logistic()
                               )

out_sig_I = pnl.TransferMechanism(name="sig_outs_I",
                                  size=len(nouns),
                                  function=psyneulink.core.components.functions.transferfunctions.Logistic()
                                  )

out_sig_is = pnl.TransferMechanism(name="sig_outs_is",
                                   size=len(is_list),
                                   function=psyneulink.core.components.functions.transferfunctions.Logistic()
 )

out_sig_has = pnl.TransferMechanism(name="sig_outs_has",
                                    size=len(has_list),
                                    function=psyneulink.core.components.functions.transferfunctions.Logistic()
                                    )
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='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_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='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
    integrator_mode=True,           # Set IntegratorFunction mode to True