Skip to content

Commit

Permalink
mg. add non-learnable higher dim projection warning
Browse files Browse the repository at this point in the history
  • Loading branch information
kmantel committed Jan 17, 2025
1 parent 497cb45 commit 134e982
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions psyneulink/core/compositions/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -6743,6 +6743,22 @@ def add_projection(self,
else:
self._pre_existing_pathway_components[PROJECTIONS].append(projection)

dim_warning_mech_exclude_classes = (ObjectiveMechanism, ControlMechanism, CompositionInterfaceMechanism)
if (
(projection.sender.socket_dim > 2 or projection.receiver.socket_dim > 2)
and projection.matrix.base.ndim == 2
and not projection.parameters.matrix._user_specified
and not isinstance(sender_mechanism, dim_warning_mech_exclude_classes)
and not isinstance(receiver_mechanism, dim_warning_mech_exclude_classes)
):
warnings.warn(
f"{projection} was auto-assigned a 2D matrix {projection.defaults.matrix}"
" while its sender or receiver is higher than 2D. This projection won't be"
" learnable. To allow learning for this projection, specify a matrix of the"
" appropriate higher-dimension shape."
)
self.warned_about_unlearnable_identity_matrices = True

self.needs_update_graph = True
self.needs_update_graph_processing = True
self.needs_update_scheduler = True
Expand Down

0 comments on commit 134e982

Please sign in to comment.