Skip to content

Commit

Permalink
• recurrenttransfermechanism.py
Browse files Browse the repository at this point in the history
  _instantiate_attributes_after_function:
  revise call to _update_default_variable to use energy.variable instead of value
  • Loading branch information
jdcpni committed Nov 15, 2024
1 parent 20ca515 commit 1d88f42
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class Stability(ObjectiveFunction):
length of array for which stability is calculated.
matrix : list, np.ndarray, function keyword, or MappingProjection : default HOLLOW_MATRIX
weight matrix from each element of `variable <Stability.variablity>` to each other; if a matrix other
weight matrix from each element of `variable <Stability.variable>` to each other; if a matrix other
than HOLLOW_MATRIX is assigned, it is convolved with HOLLOW_MATRIX to eliminate self-connections from the
stability calculation.
Expand Down Expand Up @@ -544,7 +544,7 @@ class Energy(Stability):
length of array for which energy is calculated.
matrix : list, np.ndarray, or matrix keyword
weight matrix from each element of `variable <Energy.variablity>` to each other; if a matrix other
weight matrix from each element of `variable <Energy.variable>` to each other; if a matrix other
than INVERSE_HOLLOW_MATRIX is assigned, it is convolved with HOLLOW_MATRIX to eliminate self-connections from
the energy calculation.
Expand Down Expand Up @@ -581,13 +581,13 @@ def __init__(self,
super().__init__(
default_variable=default_variable,
input_shapes=input_shapes,
metric=ENERGY,
matrix=matrix,
transfer_fct=transfer_fct,
normalize=normalize,
params=params,
owner=owner,
prefs=prefs)
metric=ENERGY,
matrix=matrix,
transfer_fct=transfer_fct,
normalize=normalize,
params=params,
owner=owner,
prefs=prefs)


class Entropy(Stability):
Expand Down Expand Up @@ -654,7 +654,7 @@ class Entropy(Stability):
length of array for which energy is calculated.
matrix : list, np.ndarray, or matrix keyword
weight matrix from each element of `variable <Entropy.variablity>` to each other; if a matrix other
weight matrix from each element of `variable <Entropy.variable>` to each other; if a matrix other
than INVERSE_HOLLOW_MATRIX is assigned, it is convolved with HOLLOW_MATRIX to eliminate self-connections from
the entropy calculation.
Expand All @@ -680,17 +680,19 @@ class Entropy(Stability):
@check_user_specified
def __init__(self,
default_variable=None,
input_shapes=None,
normalize:bool=None,
# matrix=None,
matrix=None,
transfer_fct=None,
params=None,
owner=None,
prefs=None):

super().__init__(
default_variable=default_variable,
input_shapes=input_shapes,
metric=ENTROPY,
# matrix=matrix,
matrix=matrix,
transfer_fct=transfer_fct,
normalize=normalize,
params=params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -975,30 +975,16 @@ def _instantiate_attributes_after_function(self, context=None):
self.configure_learning(context=context)

if ENERGY_OUTPUT_PORT_NAME in self.output_ports.names:
energy = Stability(self.defaults.variable,
metric=ENERGY,
# transfer_fct=self.function, # Not supporred for LLVM
matrix=matrix)
# energy = Energy(self.defaults.variable,
# # transfer_fct=self.function, # Not supported for LLVM
# matrix=matrix)

# self.output_ports[ENERGY_OUTPUT_PORT_NAME]._calculate = energy.function
energy = Energy(self.defaults.variable,
matrix=matrix)
self.output_ports[ENERGY_OUTPUT_PORT_NAME].function = energy
self.output_ports[ENERGY_OUTPUT_PORT_NAME]._update_default_variable(energy.variable, context)

if ENTROPY_OUTPUT_PORT_NAME in self.output_ports.names:
if self.function.bounds == (0,1) or self.clip == (0,1):
entropy = Stability(self.defaults.variable,
metric=ENTROPY,
# transfer_fct=self.function, # Not supported for LLVM
matrix=matrix)
# entropy = Entropy(self.defaults.variable,
# # transfer_fct=self.function, # Not supported for LLVM
# matrix=matrix)
# self.output_ports[ENTROPY_OUTPUT_PORT_NAME]._calculate = entropy.function
entropy = Entropy(self.defaults.variable)
self.output_ports[ENTROPY_OUTPUT_PORT_NAME].function = entropy
self.output_ports[ENERGY_OUTPUT_PORT_NAME]._update_default_variable(entropy.variable, context)
self.output_ports[ENTROPY_OUTPUT_PORT_NAME]._update_default_variable(entropy.variable, context)
else:
del self.output_ports[ENTROPY_OUTPUT_PORT_NAME]

Expand Down

0 comments on commit 1d88f42

Please sign in to comment.