Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
* 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
kmantel committed Feb 5, 2018
2 parents 3e7cd3d + d99bd4e commit 6949e0d
Show file tree
Hide file tree
Showing 61 changed files with 3,678 additions and 1,010 deletions.
2 changes: 1 addition & 1 deletion .idea/runConfigurations/EVC_Gratton.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/Nieuwenhuis_documented.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/runConfigurations/Scratch_Pad.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/runConfigurations/Tests.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/runConfigurations/_Gating_Mechanism.xml

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.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/scratch.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/scratch_1.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 2 additions & 11 deletions Scripts/Examples/EVC-Gratton.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
# Control Parameters
signalSearchRange = np.arange(0.8, 2.0, 0.2)

test_mech = pnl.TransferMechanism(size=3)

# 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))
Expand Down Expand Up @@ -116,7 +114,7 @@

RewardProcess = pnl.Process(
default_variable=[0],
pathway=[Reward, test_mech],
pathway=[Reward],
prefs=process_prefs,
name='RewardProcess'
)
Expand All @@ -133,7 +131,6 @@
controller=pnl.EVCControlMechanism,
enable_controller=True,
monitor_for_control=[
# (test_mech, None, None, np.ones((3,1))),
Reward,
Decision.PROBABILITY_UPPER_THRESHOLD,
('OFFSET RT', 1, -1),
Expand All @@ -142,18 +139,12 @@
name='EVC Gratton System'
)

# control_mech = pnl.EVCControlMechanism(name='NEW CONTROLLER',
# objective_mechanism = [(test_mech, None, None, np.ones((3,1)))],
# )
# mySystem.controller = control_mech
# control_mech.assign_as_controller(mySystem)

# Show characteristics of system:
mySystem.show()
mySystem.controller.show()

# Show graph of system (with control components)
mySystem.show_graph(show_control=pnl.ALL, show_dimensions=pnl.ALL)
mySystem.show_graph(show_control=True)

# configure EVC components
mySystem.controller.control_signals[0].intensity_cost_function = pnl.Exponential(rate=0.8046).function
Expand Down
158 changes: 158 additions & 0 deletions Scripts/Examples/EVC_MARKUS_control.py
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()

7 changes: 5 additions & 2 deletions Scripts/Examples/Leabra-Demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
warnings.filterwarnings("ignore", message=r".*numpy.dtype size changed.*")

random_seed_value = 1 # feel free to change this value
random.seed(random_seed_value) # setting the random seed ensures the two Leabra networks are identical (see line 68)
random.seed(random_seed_value)
num_trials = 10 # how many trials should we run?
hidden_layers = 4 # how many hidden layers are there?
hidden_sizes = [2, 3, 4, 5] # how big is each hidden layer?
Expand Down Expand Up @@ -90,7 +90,10 @@
print('\nRunning Leabra in Leabra...')
start_time = time.process_time()
for i in range(num_trials):
pnl.train_leabra_network(leabra_net, input_pattern[i].copy(), training_pattern[i].copy())
if train_flag is True:
pnl.train_leabra_network(leabra_net, input_pattern[i].copy(), training_pattern[i].copy())
else:
pnl.run_leabra_network(leabra_net, input_pattern[i].copy())
end_time = time.process_time()
print('Time to run Leabra on its own: ', end_time - start_time, "seconds")
print('Leabra Output: ', [unit.act_m for unit in leabra_net.layers[-1].units], type([unit.act_m for unit in leabra_net.layers[-1].units][0]))
Loading

0 comments on commit 6949e0d

Please sign in to comment.