-
Notifications
You must be signed in to change notification settings - Fork 29
/
Gilbert_Shallice_debugging_Interactive_activation
209 lines (171 loc) · 10.2 KB
/
Gilbert_Shallice_debugging_Interactive_activation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# this scrip implements Gilbert and Shallice 2002 PDP Task Switching Model
import numpy as np
import psyneulink as pnl
### LAYERS
WORD_INPUT_LAYER = pnl.TransferMechanism(size = 3,
function=pnl.Linear,
name='WORD INPUT LAYER')
COLOR_INPUT_LAYER = pnl.TransferMechanism(size = 3,
function=pnl.Linear,
name='COLOR INPUT LAYER')
WORD_OUTPUT_LAYER = pnl.RecurrentTransferMechanism(size = 3,
auto=0.0,
hetero=0.0,#-2.0,
function=pnl.Linear(),
# integrator_function= pnl.InteractiveActivation(rate = 0.0015, decay=0.0, offset=-6),
name='WORD OUTPUT LAYER')
WORD_OUTPUT_LAYER.set_log_conditions('value')
WORD_OUTPUT_LAYER.set_log_conditions('InputPort-0')
COLOR_OUTPUT_LAYER = pnl.RecurrentTransferMechanism(size = 3,
auto=0.0,
hetero=0.0,#-2.0,
function=pnl.Linear(),
integrator_function= pnl.InteractiveActivation(rate = 0.0015, decay=0.0, offset=-6),
name='COLOR OUTPUT LAYER')
COLOR_OUTPUT_LAYER.set_log_conditions('value')
TASK_DEMAND_LAYER = pnl.RecurrentTransferMechanism(size = 2,
auto=0.0,
hetero=0.0,#-2.0,
function=pnl.Linear(),
integrator_function= pnl.InteractiveActivation(rate = 0.0015, decay=0.0, offset=-6),
name='TASK DEMAND LAYER')
TASK_DEMAND_LAYER.set_log_conditions('value')
### WEIGHTS
# WORD INPUT TO WORD OUTPUT
word_weights = pnl.MappingProjection(matrix=np.matrix([[3.5, 0.0, 0.0],
[0.0, 3.5, 0.0],
[0.0, 0.0, 3.5]]),
name='WORD_WEIGHTS')
# COLOR INPUT TO COLOR OUTPUT
color_weights = pnl.MappingProjection(matrix=np.matrix([[1.9, 0.0, 0.0],
[0.0, 1.9, 0.0],
[0.0, 0.0, 1.9]]),
name='COLOR_WEIGHTS')
# WORD INPUT to TASK DEMAND LAYER
word_task_demand_weights = pnl.MappingProjection(matrix=np.matrix([[1.0, 1.0],
[1.0, 1.0],
[1.0, 1.0]]),
name='WORD_TASK_DEMAND_WEIGHTS')
# COLOR INPUT to TASK DEMAND LAYER
color_task_demand_weights = pnl.MappingProjection(matrix=np.matrix([[1.0, 1.0],
[1.0, 1.0],
[1.0, 1.0]]),
name='COLOR_TASK_DEMAND_WEIGHTS')
# # TASK DEMAND TO WORD OUTPUT
# task_demand_word_output_weights = pnl.MappingProjection(matrix=np.matrix([[2.5, 2.5, 2.5],
# [-2.5, -2.5, -2.5]]),
# name='TASK_DEMAND_WORD_OUTPUT_WEIGHTS')
#
# # TASK DEMAND TO COLOR OUTPUT
# task_demand_color_output_weights = pnl.MappingProjection(matrix=np.matrix([[-2.5, -2.5, -2.5],
# [2.5, 2.5, 2.5]]),
# name='TASK_DEMAND_COLOR_OUTPUT_WEIGHTS')
# # WORD OUTPUT TO TASK DEMAND
# word_output_task_demand_weights = pnl.MappingProjection(matrix=np.matrix([[1.0, -1.0],
# [1.0, -1.0],
# [1.0, -1.0]]),
# name='WORD_OUTPUT_TASK_DEMAND_WEIGHTS')
#
# # WORD OUTPUT TO TASK DEMAND
# color_output_task_demand_weights = pnl.MappingProjection(matrix=np.matrix([[-1.0, 1.0],
# [-1.0, 1.0],
# [-1.0, 1.0]]),
# name='COLOR_OUTPUT_TASK_DEMAND_WEIGHTS')
#
# # WORD OUTPUT to COLOR OUTPUT
# word_output_color_output_weights = pnl.MappingProjection(matrix=np.matrix([[0.0, -2.0, -2.0],
# [-2.0, 0.0, -2.0],
# [-2.0, -2.0, 0.0]]),
# name='WORD_OUTPUT_COLOR_OUTPUT_WEIGHTS')
#
# # WORD OUTPUT to COLOR OUTPUT
# color_output_word_output_weights = pnl.MappingProjection(matrix=np.matrix([[0.0, -2.0, -2.0],
# [-2.0, 0.0, -2.0],
# [-2.0, -2.0, 0.0]]),
# name='COLOR_OUTPUT_WORD_OUTPUT_WEIGHTS')
# # WORD OUTPUT TO TASK DEMAND
# word_output_output_to_task_demand_weights = pnl.MappingProjection(matrix=np.matrix([[1.0, 1.0],
# [1.0, 1.0],
# [1.0, 1.0]]),
# name='WORD_COLOR_OUTPUT_TASK_DEMAND_WEIGHTS')
#
# # COLOR OUTPUT TO TASK DEMAND
# color_output_output_to_task_demand_weights = pnl.MappingProjection(matrix=np.matrix([[1.0, 1.0],
# [1.0, 1.0],
# [1.0, 1.0]]),
# name='COLOR_COLOR_OUTPUT_TASK_DEMAND_WEIGHTS')
#
### COMPOSITION
Gilbert_Shallice_System = pnl.Composition(name="Gilbert_Shallice_System")
### ADD pathways
### pathway word input word output
words_input_output_pathway = [WORD_INPUT_LAYER,
word_weights,
WORD_OUTPUT_LAYER]
Gilbert_Shallice_System.add_linear_processing_pathway(pathway=words_input_output_pathway)
### pathway color input color output
color_input_output_pathway = [COLOR_INPUT_LAYER,
color_weights,
COLOR_OUTPUT_LAYER]
Gilbert_Shallice_System.add_linear_processing_pathway(pathway=color_input_output_pathway)
# # PATHWAY: TASK WORD OUTPUT
# task_word_output_pathway = [TASK_DEMAND_LAYER,
# task_demand_word_output_weights,
# WORD_OUTPUT_LAYER]
# Gilbert_Shallice_System.add_linear_processing_pathway(pathway=task_word_output_pathway)
#
# # Pathway: Task demand color output pathway
# task_color_output_pathway = [TASK_DEMAND_LAYER,
# task_demand_color_output_weights,
# COLOR_OUTPUT_LAYER]
# Gilbert_Shallice_System.add_linear_processing_pathway(pathway=task_color_output_pathway)
# #
### Pathway: word input task demand
word_input_task_pathway = [WORD_INPUT_LAYER,
word_task_demand_weights,
TASK_DEMAND_LAYER]
Gilbert_Shallice_System.add_linear_processing_pathway(pathway=word_input_task_pathway)
### Pathway: color input task demand
color_input_task_pathway = [COLOR_INPUT_LAYER,
color_task_demand_weights,
TASK_DEMAND_LAYER]
Gilbert_Shallice_System.add_linear_processing_pathway(pathway=color_input_task_pathway)
# ### Pathway: Word output Task
# word_output_task_pathway = [WORD_OUTPUT_LAYER,
# word_output_task_demand_weights,
# TASK_DEMAND_LAYER]
# Gilbert_Shallice_System.add_linear_processing_pathway(pathway=word_output_task_pathway)
#
# ### Pathway: Color output Task
# color_output_task_pathway = [COLOR_OUTPUT_LAYER,
# color_output_task_demand_weights,
# TASK_DEMAND_LAYER]
# Gilbert_Shallice_System.add_linear_processing_pathway(pathway=color_output_task_pathway)
#
# ### Pathway: Color output Word output
# color_output_word_output_pathway = [COLOR_OUTPUT_LAYER,
# color_output_word_output_weights,
# WORD_OUTPUT_LAYER]
# Gilbert_Shallice_System.add_linear_processing_pathway(pathway=color_output_word_output_pathway)
#
# ### Pathway: Color output Word output
# word_output_color_output_pathway = [WORD_OUTPUT_LAYER,
# word_output_color_output_weights,
# COLOR_OUTPUT_LAYER]
# Gilbert_Shallice_System.add_linear_processing_pathway(pathway=word_output_color_output_pathway)
## specify terminal layers (can only specify one terminal layer at a time)
Gilbert_Shallice_System.add_required_node_role(WORD_OUTPUT_LAYER, pnl.NodeRole.TERMINAL)
Gilbert_Shallice_System.add_required_node_role(COLOR_OUTPUT_LAYER, pnl.NodeRole.TERMINAL)
Gilbert_Shallice_System._analyze_graph()
Gilbert_Shallice_System.show_graph()
input_dict = {COLOR_INPUT_LAYER: [1, 0, 0],
WORD_INPUT_LAYER: [1, 0, 0]
# TASK_DEMAND_LAYER: [1, 0]
}
Gilbert_Shallice_System.run(num_trials=5,
inputs=input_dict)
WORD_INPUT_LAYER.log.print_entries()
WORD_OUTPUT_LAYER.log.print_entries()
COLOR_OUTPUT_LAYER.log.print_entries()
TASK_DEMAND_LAYER.log.print_entries()
### SYSTEM