-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
* devel: Feat/rl/for mads (#652) Feat/rl/for mads (#651) Removed Print Statements (#650) cleaning up documentation to match how LinearMatrix works in all cases typo in linear matrix function validation simplifying non-projection branch of validation on LinearMatrix function and adding more pytests default_variable: let argument override input_states variable spec if compatible adding pytests for possible combinations of variable and matrix specifications for LinearMatrix as a function of a mechanism adding validation comparing matrix to variable when LinearMatrix function is called by a mechanism; creating square full connectivity matrix that matches variable when matrix is not specified tutorial: reenable graph drawing; requires graphviz package tutorial: clear outputs Lena Program 1 Bugfix (#648) Hebbian learning fix (#647) User defined function updates (#646) adding working version of LinearMatrix function pytest (only works because default_variable is specified on both the mechanism and the function) fix input_states argparsing to not be dependent on default_variable or size args tests: ensure leabra tests get skipped if module is not available splitting linear matrix function's validation into two branches because matrix is handled differently when the function is called by a projection vs a receiver docstring wording change Docs/models/title changes (#645) Docs/nieuwenhuis/edits (#644) adding pytest for ProcessingMechanism with LinearMatrix function to begin debugging why this fn only works in Projections removing unrestrictedtransfermechanism file because this mechanism is now called ProcessingMechanism and does not need its own file adding parameter state docs examples back in with doctest SKIP revising proccessing mechanism docs because it is not an executable mechanism (not just an ABC) renaming UnrestrictedProcessingMechanism --> ProcessingMechanism and moving code into processingmechanism.py (which formerly only contained ProcessingMechanism_Base Leabra Update (#642) DDM: update is_finished to work on functions with any dimensional variable skipping transfer mechanism doc tests skipping transfer mechanism doc tests minor documentation changes -typos and formatting mistakes reorganizing integrator mechanism pytests for reinitialize overwriting AGTUtilityIntegrator's reinitialize property - requires custom reinitialization of short term and long term utility overwriting FHNIntegrator's reinitialize property - requires custom reinitialization of v, w, time, value overwriting reinitialize property on DriftDiffusion Integrator so that time can also be reset documenting reinitialize on all Integrator functions and fixing a typo in transfer mechanism docs (initial_value --> initializer) continuing to add docs and examples for reinitialize, and cleaning up TransferMechanism docs along the way fixing tutorial indexing bug refactoring is_finished as a property so that it is always up to date, even when values change in between executions (i.e. if threshold was crossed and then reinitialize was used) fixing bug in transfer mechanism documention examples (np.array typo) renaming reset_intializer --> reinitialize adding unrestricted mechanism pytests to confirm that mechanism can be constructed and executed with any function -- identified two exceptions (linear matrix and back prop) adding a new mechanism that has no restrictions on which functions can be used commenting out show graph lines in tutorial for now because graphviz is not imported on testing server adding updated version of tutorial from Justin revising transfer mechanism documentation -- 'creating' section commenting out show_graph in EVC gratton pytest so that this line does not run on Jenkins adding TransferMechanism pytests to verify previous_value persists over multiple runs/executions AND previous_value resets whenever reset_initializer is used edited NieuwenhuisModel docs tutorial: support execution on mybinder.org tutorial: remove old version - new version is in tutorial/ dir • Niewenhuis model - docstring edits - adding integrator_mode and integrator_function attr documentation for all transfer mechanism types revising outdated documentation for transfer mechanism noise fixed bug in plotting Nieuwenhuis Model updated Nieuwenhuis documentation adding attrs that were missing from LCA mechanism docs and revising related documentation
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
import numpy as np | ||
import psyneulink as pnl | ||
|
||
# Control Parameters | ||
signalSearchRange = np.arange(0.8, 2.0, 0.2) # why 0.8 to 2.0 in increments of 0.2 | ||
|
||
|
||
# test_mech = pnl.TransferMechanism(size=3) | ||
|
||
# Stimulus Mechanisms | ||
Target_Stim = pnl.TransferMechanism(name='Target Stimulus', function=pnl.Linear) | ||
Flanker_Stim = pnl.TransferMechanism(name='Flanker Stimulus', function=pnl.Linear) | ||
|
||
# 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})))) | ||
Target_Rep.set_log_conditions('value') # Log Target_Rep | ||
Target_Rep.loggable_items | ||
|
||
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.loggable_items | ||
# Processing Mechanism (Automatic) | ||
Automatic_Component = pnl.TransferMechanism(name='Automatic Component',function=pnl.Linear) | ||
Automatic_Component.loggable_items | ||
Automatic_Component.set_log_conditions('value') | ||
|
||
# Decision Mechanisms | ||
Decision = pnl.DDM(function=pnl.BogaczEtAl( | ||
drift_rate=(0.5), | ||
threshold=(1.0), | ||
# noise=(0.8), | ||
starting_point=(0), | ||
t0=0.15 | ||
),name='Decision', | ||
output_states=[ | ||
pnl.DECISION_VARIABLE, | ||
pnl.RESPONSE_TIME, | ||
pnl.PROBABILITY_UPPER_THRESHOLD, | ||
{ | ||
pnl.NAME: 'OFFSET RT', | ||
pnl.INDEX: 2, | ||
pnl.CALCULATE: pnl.Linear(0, slope=1.0, intercept=1).function | ||
} | ||
],) #drift_rate=(1.0),threshold=(0.2645),noise=(0.5),starting_point=(0), t0=0.15 | ||
Decision.set_log_conditions('DECISION_VARIABLE') | ||
Decision.set_log_conditions('value') | ||
Decision.set_log_conditions('PROBABILITY_UPPER_THRESHOLD') | ||
Decision.set_log_conditions('InputState-0') | ||
|
||
Decision.loggable_items | ||
|
||
# Outcome Mechanisms: | ||
Reward = pnl.TransferMechanism(name='Reward') | ||
|
||
# Processes: | ||
TargetControlProcess = pnl.Process( | ||
default_variable=[0], | ||
pathway=[Target_Stim, Target_Rep, Decision], | ||
name='Target Control Process' | ||
) | ||
|
||
FlankerControlProcess = pnl.Process( | ||
default_variable=[0], | ||
pathway=[Flanker_Stim, Flanker_Rep, Decision], | ||
name='Flanker Control Process' | ||
) | ||
|
||
TargetAutomaticProcess = pnl.Process( | ||
default_variable=[0], | ||
pathway=[Target_Stim, Automatic_Component, Decision], | ||
name='Target Automatic Process' | ||
) | ||
|
||
FlankerAutomaticProcess = pnl.Process( | ||
default_variable=[0], | ||
pathway=[Flanker_Stim, Automatic_Component, Decision], | ||
name='Flanker1 Automatic Process' | ||
) | ||
|
||
# RewardProcess = pnl.Process( | ||
# default_variable=[0], | ||
# pathway=[Reward, test_mech], | ||
# name='RewardProcess' | ||
# ) | ||
|
||
|
||
# System: | ||
mySystem = pnl.System(processes=[TargetControlProcess, | ||
FlankerControlProcess, | ||
TargetAutomaticProcess, | ||
FlankerAutomaticProcess], | ||
controller=pnl.EVCControlMechanism, | ||
enable_controller=True, | ||
monitor_for_control=[ | ||
# (None, None, np.ones((2,1))), | ||
# Reward, | ||
Decision.PROBABILITY_UPPER_THRESHOLD, | ||
('OFFSET RT', 1, -1), | ||
], | ||
name='EVC Markus System') | ||
|
||
# Show characteristics of system: | ||
mySystem.show() | ||
# mySystem.controller.show() | ||
|
||
# Show graph of system | ||
# mySystem.show_graph(show_control=True)# show_control=True,show_dimensions=True) | ||
|
||
|
||
|
||
|
||
#Markus: incongruent trial weights: | ||
|
||
# f = np.array([1,1]) | ||
# W_inc = np.array([[1.0, 0.0],[0.0, 1.5]]) | ||
# W_con = np.array([[1.0, 0.0],[1.5, 0.0]]) | ||
|
||
|
||
# generate stimulus environment | ||
nTrials = 5 | ||
targetFeatures = [1.0] | ||
flankerFeatures_inc = [-1.5] | ||
# flankerFeatures_con = [1.5, 0] | ||
# reward = [100, 100, 100] | ||
|
||
|
||
targetInputList = targetFeatures | ||
flankerInputList = flankerFeatures_inc | ||
# rewardList = reward | ||
|
||
|
||
|
||
stim_list_dict = { | ||
Target_Stim: targetInputList, | ||
Flanker_Stim: flankerInputList, | ||
# Reward: rewardList | ||
|
||
} | ||
|
||
def x(): | ||
print(Decision.output_states[pnl.PROBABILITY_UPPER_THRESHOLD].value) | ||
|
||
mySystem.run(num_trials=nTrials, | ||
inputs=stim_list_dict, | ||
call_after_trial=x) | ||
|
||
# Flanker_Rep.log.print_entries() | ||
# Target_Rep.log.print_entries() | ||
Decision.log.print_entries() | ||
|