Skip to content

Commit

Permalink
treewide: rename Component arg size -> input_shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
kmantel committed Oct 3, 2024
1 parent d60d535 commit 938e7b6
Show file tree
Hide file tree
Showing 147 changed files with 1,300 additions and 1,207 deletions.
10 changes: 5 additions & 5 deletions Scripts/Debug/Gilbert_Shallice_debugging_Interactive_activation
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import psyneulink as pnl


### LAYERS
WORD_INPUT_LAYER = pnl.TransferMechanism(size = 3,
WORD_INPUT_LAYER = pnl.TransferMechanism(input_shapes = 3,
function=pnl.Linear,
name='WORD INPUT LAYER')

COLOR_INPUT_LAYER = pnl.TransferMechanism(size = 3,
COLOR_INPUT_LAYER = pnl.TransferMechanism(input_shapes = 3,
function=pnl.Linear,
name='COLOR INPUT LAYER')


WORD_OUTPUT_LAYER = pnl.RecurrentTransferMechanism(size = 3,
WORD_OUTPUT_LAYER = pnl.RecurrentTransferMechanism(input_shapes = 3,
auto=0.0,
hetero=0.0,#-2.0,
function=pnl.Linear(),
Expand All @@ -25,7 +25,7 @@ WORD_OUTPUT_LAYER.set_log_conditions('InputPort-0')



COLOR_OUTPUT_LAYER = pnl.RecurrentTransferMechanism(size = 3,
COLOR_OUTPUT_LAYER = pnl.RecurrentTransferMechanism(input_shapes = 3,
auto=0.0,
hetero=0.0,#-2.0,
function=pnl.Linear(),
Expand All @@ -35,7 +35,7 @@ COLOR_OUTPUT_LAYER = pnl.RecurrentTransferMechanism(size = 3,
COLOR_OUTPUT_LAYER.set_log_conditions('value')


TASK_DEMAND_LAYER = pnl.RecurrentTransferMechanism(size = 2,
TASK_DEMAND_LAYER = pnl.RecurrentTransferMechanism(input_shapes = 2,
auto=0.0,
hetero=0.0,#-2.0,
function=pnl.Linear(),
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Debug/Hebbian_Simon.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Hebb_comp = pnl.Composition()

Hebb_mech=pnl.RecurrentTransferMechanism(
size=sizeF,
input_shapes=sizeF,
function=pnl.Linear,
#integrator_mode = True,
#integration_rate = 0.5,
Expand Down
12 changes: 6 additions & 6 deletions Scripts/Debug/Jason_Reward_rate_with_penalty_with_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ def get_stroop_model(unit_noise_std=.01, dec_noise_std=.1):
punish = pnl.TransferMechanism(name='punish')

inp_clr = pnl.TransferMechanism(
size=N_UNITS, function=pnl.Linear, name='COLOR INPUT'
input_shapes=N_UNITS, function=pnl.Linear, name='COLOR INPUT'
)
inp_wrd = pnl.TransferMechanism(
size=N_UNITS, function=pnl.Linear, name='WORD INPUT'
input_shapes=N_UNITS, function=pnl.Linear, name='WORD INPUT'
)
# task layer, represent the task instruction; color naming / word reading
inp_task = pnl.TransferMechanism(
size=N_UNITS, function=pnl.Linear, name='TASK'
input_shapes=N_UNITS, function=pnl.Linear, name='TASK'
)
# hidden layer for color and word
hid_clr = pnl.TransferMechanism(
size=N_UNITS,
input_shapes=N_UNITS,
function=hidden_func,
integrator_mode=True,
integration_rate=integration_rate,
Expand All @@ -92,7 +92,7 @@ def get_stroop_model(unit_noise_std=.01, dec_noise_std=.1):
name='COLORS HIDDEN'
)
hid_wrd = pnl.TransferMechanism(
size=N_UNITS,
input_shapes=N_UNITS,
function=hidden_func,
integrator_mode=True,
integration_rate=integration_rate,
Expand All @@ -102,7 +102,7 @@ def get_stroop_model(unit_noise_std=.01, dec_noise_std=.1):
)
# output layer
output = pnl.TransferMechanism(
size=N_UNITS,
input_shapes=N_UNITS,
function=pnl.Logistic,
integrator_mode=True,
integration_rate=integration_rate,
Expand Down
18 changes: 12 additions & 6 deletions Scripts/Debug/Markus Stroop.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@
import psyneulink.core.components.functions.stateful.integratorfunctions
import psyneulink.core.components.functions.nonstateful.transferfunctions

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

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

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

Expand All @@ -26,14 +29,16 @@
# randomly distributed noise to the net input
# time averaging = integration_rate = 0.1
unit_noise = 0.001
colors_hidden_layer = pnl.TransferMechanism(size=2,
colors_hidden_layer = pnl.TransferMechanism(
input_shapes=2,
function=psyneulink.core.components.functions.nonstateful.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.nonstateful.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,
words_hidden_layer = pnl.TransferMechanism(
input_shapes=2,
function=psyneulink.core.components.functions.nonstateful.transferfunctions.Logistic(gain=1.0, x_0=4.0),
integrator_mode=True,
noise=psyneulink.core.components.functions.nonstateful.distributionfunctions.NormalDist(mean=0, standard_deviation=unit_noise).function,
Expand All @@ -43,7 +48,8 @@
# OUTPUT UNITS

# Response layer, provide input to accumulator, responses: ('red', 'green')
response_layer = pnl.TransferMechanism(size=2,
response_layer = pnl.TransferMechanism(
input_shapes=2,
function=psyneulink.core.components.functions.nonstateful.transferfunctions.Logistic,
integrator_mode=True,
noise=psyneulink.core.components.functions.nonstateful.distributionfunctions.NormalDist(mean=0, standard_deviation=unit_noise).function,
Expand Down
6 changes: 3 additions & 3 deletions Scripts/Debug/Predator-Prey Sebastian REDUCED.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def get_new_episode_flag():
# ************************************** PROCESSING MECHANISMS ********************************************************

# Perceptual Mechanisms
player_percept = ProcessingMechanism(size=2, function=GaussianDistort(), name="PLAYER PERCEPT")
predator_percept = ProcessingMechanism(size=2, function=GaussianDistort(), name="PREDATOR PERCEPT")
prey_percept = ProcessingMechanism(size=2, function=GaussianDistort(), name="PREY PERCEPT")
player_percept = ProcessingMechanism(input_shapes=2, function=GaussianDistort(), name="PLAYER PERCEPT")
predator_percept = ProcessingMechanism(input_shapes=2, function=GaussianDistort(), name="PREDATOR PERCEPT")
prey_percept = ProcessingMechanism(input_shapes=2, function=GaussianDistort(), name="PREY PERCEPT")

# Mechanism used to encode trialtype from environment
trial_type_input_mech = ProcessingMechanism(name="TRIAL TYPE INPUT")
Expand Down
6 changes: 3 additions & 3 deletions Scripts/Debug/Predator-Prey Sebastian.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ def get_optimal_action(observation):
# ************************************** PROCESSING MECHANISMS ********************************************************

# Perceptual Mechanisms
player_percept = ProcessingMechanism(size=prey_len, function=GaussianDistort(), name="PLAYER PERCEPT")
predator_percept = ProcessingMechanism(size=predator_len, function=GaussianDistort(), name="PREDATOR PERCEPT")
prey_percept = ProcessingMechanism(size=prey_len, function=GaussianDistort(), name="PREY PERCEPT")
player_percept = ProcessingMechanism(input_shapes=prey_len, function=GaussianDistort(), name="PLAYER PERCEPT")
predator_percept = ProcessingMechanism(input_shapes=predator_len, function=GaussianDistort(), name="PREDATOR PERCEPT")
prey_percept = ProcessingMechanism(input_shapes=prey_len, function=GaussianDistort(), name="PREY PERCEPT")

# Mechanism used to encode trialtype from environment
trial_type_input_mech = ProcessingMechanism(name="TRIAL TYPE INPUT")
Expand Down
9 changes: 5 additions & 4 deletions Scripts/Debug/StabilityFlexibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def computeAccuracy(variable):

# first element is color task attendance, second element is motion task attendance
inputLayer = pnl.TransferMechanism(#default_variable=[[0.0, 0.0]],
size=2,
input_shapes=2,
function=pnl.Linear(slope=1, intercept=0),
output_ports = [pnl.RESULT],
name='Input')
Expand All @@ -100,23 +100,24 @@ def computeAccuracy(variable):


stimulusInfo = pnl.TransferMechanism(default_variable=[[0.0, 0.0]],
size = 2,
input_shapes= 2,
function = pnl.Linear(slope=1, intercept=0),
output_ports = [pnl.RESULT],
name = "Stimulus Info")

stimulusInfo.set_log_conditions([pnl.RESULT])

controlledElement = pnl.TransferMechanism(default_variable=[[0.0, 0.0]],
size = 2,
input_shapes= 2,
function=pnl.Linear(slope=1, intercept= 0),
input_ports=pnl.InputPort(combine=pnl.PRODUCT),
output_ports = [pnl.RESULT],
name = 'Stimulus Info * Activity')

controlledElement.set_log_conditions([pnl.RESULT])

ddmCombination = pnl.TransferMechanism(size = 1,
ddmCombination = pnl.TransferMechanism(
input_shapes= 1,
function = pnl.Linear(slope=1, intercept=0),
output_ports = [pnl.RESULT],
name = "DDM Integrator")
Expand Down
29 changes: 18 additions & 11 deletions Scripts/Debug/Yotam LCA Model LLVM.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,15 @@ def get_trained_network(bipartite_graph, num_features=3, num_hidden=200, epochs=
lr = learning_rate

# Instantiate layers and projections
il = pnl.TransferMechanism(size=D_i, name='input')
cl = pnl.TransferMechanism(size=D_c, name='control')
il = pnl.TransferMechanism(input_shapes=D_i, name='input')
cl = pnl.TransferMechanism(input_shapes=D_c, name='control')

hl = pnl.TransferMechanism(size=D_h, name='hidden',
hl = pnl.TransferMechanism(
input_shapes=D_h, name='hidden',
function=pnl.Logistic(bias=-2))

ol = pnl.TransferMechanism(size=D_o, name='output',
ol = pnl.TransferMechanism(
input_shapes=D_o, name='output',
function=pnl.Logistic(bias=-2))

pih = pnl.MappingProjection(matrix=wih)
Expand Down Expand Up @@ -190,7 +192,8 @@ def get_trained_network(bipartite_graph, num_features=3, num_hidden=200, epochs=

# Apply LCA transform (values from Sebastian's code -- supposedly taken from the original LCA paper from Marius & Jay)
if attach_LCA:
lca = pnl.LCAMechanism(size=D_o,
lca = pnl.LCAMechanism(
input_shapes=D_o,
leak=leak,
competition=competition,
self_excitation=self_excitation,
Expand Down Expand Up @@ -251,14 +254,16 @@ def get_trained_network_multLCA(bipartite_graph, num_features=3, num_hidden=200,
lr = learning_rate

# Instantiate layers and projections
il = pnl.TransferMechanism(size=D_i, name='input')
cl = pnl.TransferMechanism(size=D_c, name='control')
il = pnl.TransferMechanism(input_shapes=D_i, name='input')
cl = pnl.TransferMechanism(input_shapes=D_c, name='control')

hl = pnl.TransferMechanism(size=D_h,
hl = pnl.TransferMechanism(
input_shapes=D_h,
name='hidden',
function=pnl.Logistic(bias=-2))

ol = pnl.TransferMechanism(size=D_o,
ol = pnl.TransferMechanism(
input_shapes=D_o,
name='output',
function=pnl.Logistic(bias=-2))

Expand Down Expand Up @@ -323,7 +328,8 @@ def get_trained_network_multLCA(bipartite_graph, num_features=3, num_hidden=200,

lca_matrix = get_LCA_matrix(output_dims, num_features, self_excitation, competition)

lca = pnl.RecurrentTransferMechanism(size=D_o,
lca = pnl.RecurrentTransferMechanism(
input_shapes=D_o,
matrix=lca_matrix,
integrator_mode=True,
integrator_function=lci,
Expand All @@ -339,7 +345,8 @@ def get_trained_network_multLCA(bipartite_graph, num_features=3, num_hidden=200,

# Dummy to save mnet results
if str(LCA_BIN_EXECUTE).startswith("LLVM"):
dummy = pnl.TransferMechanism(size=D_o,
dummy = pnl.TransferMechanism(
input_shapes=D_o,
name="MNET_OUT")
wrapper_composition.add_linear_processing_pathway([mnet, dummy])

Expand Down
26 changes: 16 additions & 10 deletions Scripts/Debug/Yotam LCA Model.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,15 @@ def get_trained_network(bipartite_graph, num_features=3, num_hidden=200, epochs=
lr = learning_rate

# Instantiate layers and projections
il = pnl.TransferMechanism(size=D_i, name='input')
cl = pnl.TransferMechanism(size=D_c, name='control')
il = pnl.TransferMechanism(input_shapes=D_i, name='input')
cl = pnl.TransferMechanism(input_shapes=D_c, name='control')

hl = pnl.TransferMechanism(size=D_h, name='hidden',
hl = pnl.TransferMechanism(
input_shapes=D_h, name='hidden',
function=pnl.Logistic(bias=-2))

ol = pnl.TransferMechanism(size=D_o, name='output',
ol = pnl.TransferMechanism(
input_shapes=D_o, name='output',
function=pnl.Logistic(bias=-2))

pih = pnl.MappingProjection(matrix=wih)
Expand Down Expand Up @@ -174,7 +176,8 @@ def get_trained_network(bipartite_graph, num_features=3, num_hidden=200, epochs=

# Apply LCA transform (values from Sebastian's code -- supposedly taken from the original LCA paper from Marius & Jay)
if attach_LCA:
lca = pnl.LCAMechanism(size=D_o,
lca = pnl.LCAMechanism(
input_shapes=D_o,
leak=leak,
competition=competition,
self_excitation=self_excitation,
Expand Down Expand Up @@ -237,14 +240,16 @@ def get_trained_network_multLCA(bipartite_graph, num_features=3, num_hidden=200,
lr = learning_rate

# Instantiate layers and projections
il = pnl.TransferMechanism(size=D_i, name='input')
cl = pnl.TransferMechanism(size=D_c, name='control')
il = pnl.TransferMechanism(input_shapes=D_i, name='input')
cl = pnl.TransferMechanism(input_shapes=D_c, name='control')

hl = pnl.TransferMechanism(size=D_h,
hl = pnl.TransferMechanism(
input_shapes=D_h,
name='hidden',
function=pnl.Logistic(bias=-2))

ol = pnl.TransferMechanism(size=D_o,
ol = pnl.TransferMechanism(
input_shapes=D_o,
name='output',
function=pnl.Logistic(bias=-2))

Expand Down Expand Up @@ -304,7 +309,8 @@ def get_trained_network_multLCA(bipartite_graph, num_features=3, num_hidden=200,

lca_matrix = get_LCA_matrix(output_dims, num_features, self_excitation, competition)

lca = pnl.RecurrentTransferMechanism(size=D_o,
lca = pnl.RecurrentTransferMechanism(
input_shapes=D_o,
matrix=lca_matrix,
integrator_mode=True,
integrator_function=lci,
Expand Down
6 changes: 3 additions & 3 deletions Scripts/Debug/bryant_lca_with_termination.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import psyneulink as pnl

cueInterval = pnl.TransferMechanism(default_variable=[[0.0]],
size=1,
input_shapes=1,
function=pnl.Linear(slope=1, intercept=0),
output_ports=[pnl.RESULT],
name='Cue-Stimulus Interval')

taskLayer = pnl.TransferMechanism(default_variable=[[0.0, 0.0]],
size=2,
input_shapes=2,
function=pnl.Linear(slope=1, intercept=0),
output_ports=[pnl.RESULT],
name='Task Input [I1, I2]')

activation = pnl.LCAMechanism(default_variable=[[0.0, 0.0]],
size=2,
input_shapes=2,
function=pnl.Logistic(gain=1),
leak=.5,
competition=2,
Expand Down
Loading

0 comments on commit 938e7b6

Please sign in to comment.