Ejemplo n.º 1
0
 def test_log_initialization(self):
     T = pnl.TransferMechanism(
         prefs={
             pnl.LOG_PREF:
             pnl.PreferenceEntry(pnl.LogCondition.INITIALIZATION,
                                 pnl.PreferenceLevel.INSTANCE)
         })
     assert T.logged_items == {'value': 'INITIALIZATION'}
Ejemplo n.º 2
0
 def test_delivery_initialization(self):
     con_with_rpc_pipeline = pnl.Context(rpc_pipeline=Queue())
     pipeline = con_with_rpc_pipeline.rpc_pipeline
     T = pnl.TransferMechanism(
             prefs={pnl.DELIVERY_PREF: pnl.PreferenceEntry(pnl.LogCondition.EXECUTION, pnl.PreferenceLevel.INSTANCE)}
     )
     comp = pnl.Composition(name='comp', nodes=[T])
     comp.run([1], context=con_with_rpc_pipeline)
     actual = []
     while not pipeline.empty():
         actual.append(pipeline.get())
     assert all([
         len(actual) == 1,
         actual[0].time == '0:0:0:0',
         actual[0].value.shape == [1, 1],
         actual[0].value.data == [1.0]
     ])
Ejemplo n.º 3
0
import numpy as np
import psyneulink as pnl

# Preferences:
mechanism_prefs = pnl.ComponentPreferenceSet(
    prefs={
        pnl.VERBOSE_PREF: pnl.PreferenceEntry(False,
                                              pnl.PreferenceLevel.INSTANCE),
        # pnl.REPORT_OUTPUT_PREF: pnl.PreferenceEntry(True, pnl.PreferenceLevel.INSTANCE)
    })

process_prefs = pnl.ComponentPreferenceSet(
    reportOutput_pref=pnl.PreferenceEntry(False, pnl.PreferenceLevel.INSTANCE),
    verbose_pref=pnl.PreferenceEntry(True, pnl.PreferenceLevel.INSTANCE))

# Control Parameters
signalSearchRange = np.arange(0.8, 2.0, 0.2)

# Stimulus Mechanisms
Target_Stim = pnl.TransferMechanism(name='Target Stimulus',
                                    function=pnl.Linear(slope=0.3324))
Flanker_Stim = pnl.TransferMechanism(name='Flanker Stimulus',
                                     function=pnl.Linear(slope=0.3545221843))

# Processing Mechanisms (Control)
Target_Rep = pnl.TransferMechanism(
    name='Target Representation',
    function=pnl.Linear(slope=(
        1.0,
        pnl.ControlProjection(
            function=pnl.Linear,
    name='Flanker Stimulus',
    function=psyneulink.core.components.functions.transferfunctions.Linear(
        slope=0.3545))
Flanker_Stim.set_log_conditions('value')

# Processing Mechanisms (Control)
Target_Rep = pnl.TransferMechanism(
    name='Target Representation',
    function=psyneulink.core.components.functions.transferfunctions.Linear(
        slope=(1.0,
               pnl.ControlProjection(control_signal_params={
                   pnl.ALLOCATION_SAMPLES: signalSearchRange
               }))),
    prefs={
        pnl.LOG_PREF:
        pnl.PreferenceEntry(pnl.LogCondition.INITIALIZATION,
                            pnl.PreferenceLevel.INSTANCE)
    })
Target_Rep.set_log_conditions('value')  # Log Target_Rep
Target_Rep.set_log_conditions('slope')  # Log Target_Rep
Target_Rep.loggable_items

#log initialization

Target_Rep.log.LogCondition = 2

Flanker_Rep = pnl.TransferMechanism(
    name='Flanker Representation',
    function=psyneulink.core.components.functions.transferfunctions.Linear(
        slope=(1.0,
               pnl.ControlProjection(control_signal_params={
                   pnl.ALLOCATION_SAMPLES: signalSearchRange
Ejemplo n.º 5
0
    function=psyneulink.core.components.functions.nonstateful.
    transferfunctions.Linear(),
    default_variable=[0, 0])

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

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

comp = pnl.Composition(name='Neural Network DDM Process',
                       pathways=[[
                           myInputLayer,
                           pnl.get_matrix(pnl.RANDOM_CONNECTIVITY_MATRIX, 2,
                                          5), myHiddenLayer,
                           pnl.FULL_CONNECTIVITY_MATRIX, myDDM
                       ]])

comp.reportOutputPref = True
myInputLayer.reportOutputPref = True
myHiddenLayer.reportOutputPref = True
myDDM.reportOutputPref = pnl.PreferenceEntry(True,
                                             pnl.PreferenceLevel.INSTANCE)

comp.run([[-1, 2], [2, 3], [5, 5]])
Ejemplo n.º 6
0
test_mech = pnl.TransferMechanism(size=1)

# Stimulus Mechanisms
Target_Stim = pnl.TransferMechanism(name='Target Stimulus', function=pnl.Linear(slope=0.3324))
Target_Stim.set_log_conditions('value')
Flanker_Stim = pnl.TransferMechanism(name='Flanker Stimulus', function=pnl.Linear(slope=0.3545))
Flanker_Stim.set_log_conditions('value')

# Processing Mechanisms (Control)
Target_Rep = pnl.TransferMechanism(name='Target Representation',
                                   function=pnl.Linear(
                                       slope=(1.0, pnl.ControlProjection(
                                           control_signal_params={
                                               pnl.ALLOCATION_SAMPLES: signalSearchRange}))),
                                   prefs = {pnl.LOG_PREF: pnl.PreferenceEntry(pnl.LogCondition.INITIALIZATION, pnl.PreferenceLevel.INSTANCE)})
Target_Rep.set_log_conditions('value') # Log Target_Rep
Target_Rep.set_log_conditions('slope') # Log Target_Rep
Target_Rep.loggable_items

#log initialization

Target_Rep.log.LogCondition =2

Flanker_Rep = pnl.TransferMechanism(name='Flanker Representation',
                                    function=pnl.Linear(
                                        slope=(1.0, pnl.ControlProjection(
                                            control_signal_params={
                                                pnl.ALLOCATION_SAMPLES: signalSearchRange}))))
Flanker_Rep.set_log_conditions('value') # Log Flanker_Rep
Flanker_Rep.set_log_conditions('slope') # Log Flanker_Rep
Ejemplo n.º 7
0
def test_search_function(controller=None, **kwargs):
    result = np.array(controller.allocationPolicy).reshape(
        len(controller.allocationPolicy), -1)
    return result


def test_outcome_function(**kwargs):
    result = np.array([0])
    return result


# Preferences:
mechanism_prefs = pnl.ComponentPreferenceSet(
    prefs={
        pnl.VERBOSE_PREF:
        pnl.PreferenceEntry(False, pnl.PreferenceLevel.INSTANCE),
        pnl.REPORT_OUTPUT_PREF:
        pnl.PreferenceEntry(True, pnl.PreferenceLevel.INSTANCE)
    })

process_prefs = pnl.ComponentPreferenceSet(
    reportOutput_pref=pnl.PreferenceEntry(False, pnl.PreferenceLevel.INSTANCE),
    verbose_pref=pnl.PreferenceEntry(True, pnl.PreferenceLevel.INSTANCE))

# Control Parameters
signalSearchRange = np.arange(0.8, 2.0, 0.2)

# Stimulus Mechanisms
Target_Stim = pnl.TransferMechanism(name='Target Stimulus',
                                    function=pnl.Linear(slope=0.3324))
Flanker_Stim = pnl.TransferMechanism(name='Flanker Stimulus',