Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/ego_update_figs #3108

Merged
merged 10 commits into from
Nov 9, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,14 @@ def construct_model(model_name:str=model_params['name'],
device=device
)

# # TO GET SHOW_GRAPH FOR PNL LEARNING:
# inputs = {em.nodes['CONTEXT [QUERY]']: [[[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]],
# em.nodes['PREVIOUS STATE [QUERY]']: [[[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]],
# em.nodes['STATE [VALUE]']: [[[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]]}
# em.learn(inputs=inputs, execution_mode=ExecutionMode.Python)
# em.show_graph(show_learning=True)


prediction_layer = ProcessingMechanism(name=prediction_layer_name, input_shapes=state_size)


Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from psyneulink.core.compositions.report import ReportOutput, ReportProgress
import psyneulink as pnl

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'pnl' is not used.

# Settings for running script:

Expand All @@ -9,11 +10,13 @@
DISPLAY_MODEL = ( # Only one of the following can be uncommented:
None # suppress display of model
# { # show simple visual display of model
# 'show_pytorch': True, # show pytorch graph of model
# 'show_learning': True
# # 'show_projections_not_in_composition': True,
# # 'exclude_from_gradient_calc_style': 'dashed'# show target mechanisms for learning
# # {'show_node_structure': True # show detailed view of node structures and projections
# # 'show_pytorch': True, # show pytorch graph of model
# 'show_learning': True,
# # 'show_nested_args': {'show_learning': pnl.ALL},
# 'show_projections_not_in_composition': True,
# # 'show_nested': {'show_node_structure': True},
# # 'exclude_from_gradient_calc_style': 'dashed'# show target mechanisms for learning
# # 'show_node_structure': True # show detailed view of node structures and projections
# }
)
# RUN_MODEL = False # False => don't run the model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
# loss_spec = Loss.MSE,
learning_rate = .5,
num_optimization_steps = 10,
# execution_mode = ExecutionMode.Python,
synch_weights = RUN,
synch_values = RUN,
synch_results = RUN,
execution_mode = ExecutionMode.PyTorch,
execution_mode = ExecutionMode.Python,
# execution_mode = ExecutionMode.PyTorch,
device = CPU,
# device = MPS,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3366,8 +3366,12 @@ def derivative(self, input=None, output=None, context=None):

if output is None:
output = self.function(input, params={OUTPUT_TYPE: ALL}, context=context)
elif np.any(np.equal(0, output)) and context.source == ContextFlags.CONSTRUCTOR:
# Allow derivative to be computed when output is 0 during initialization
output = np.where(output, output==0, 1)
else:
assert not np.any(np.equal(0, output))
assert not np.any(np.equal(0, output)), \
f"Derivative of SoftMax function for '{self.owner.name}' is not defined when output is 0."

per_item = self._get_current_parameter_value(PER_ITEM, context)
if not per_item:
Expand Down
Loading