From a49b9f83dbfa0ee6149005176fbd49525ac549d6 Mon Sep 17 00:00:00 2001 From: Andrew Rowley Date: Thu, 5 May 2016 08:10:54 +0100 Subject: [PATCH] Fixed an issue with negative weights being dealt with incorrectly --- .../connectors/abstract_connector.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spynnaker/pyNN/models/neural_projections/connectors/abstract_connector.py b/spynnaker/pyNN/models/neural_projections/connectors/abstract_connector.py index 2bb1e52979..ab64d172c5 100644 --- a/spynnaker/pyNN/models/neural_projections/connectors/abstract_connector.py +++ b/spynnaker/pyNN/models/neural_projections/connectors/abstract_connector.py @@ -144,12 +144,12 @@ def _get_weight_mean(weights, connection_slices): """ Get the mean of the weights """ if isinstance(weights, RandomDistribution): - return utility_calls.get_mean(weights) + return abs(utility_calls.get_mean(weights)) elif numpy.isscalar(weights): - return weights + return abs(weights) elif hasattr(weights, "__getitem__"): return numpy.mean([ - weights[connection_slice] + numpy.abs(weights[connection_slice]) for connection_slice in connection_slices]) raise Exception("Unrecognised weight format") @@ -180,10 +180,10 @@ def _get_weight_maximum(weights, n_connections, connection_slices): return abs(max_weight) elif numpy.isscalar(weights): - return weights + return abs(weights) elif hasattr(weights, "__getitem__"): return numpy.amax([ - weights[connection_slice] + numpy.abs(weights[connection_slice]) for connection_slice in connection_slices]) raise Exception("Unrecognised weight format") @@ -204,7 +204,7 @@ def _get_weight_variance(weights, connection_slices): return 0.0 elif hasattr(weights, "__getitem__"): return numpy.var([ - weights[connection_slice] + numpy.abs(weights[connection_slice]) for connection_slice in connection_slices]) raise Exception("Unrecognised weight format") @@ -269,7 +269,7 @@ def _generate_weights(self, values, n_connections, connection_slices): " in projection {}->{}".format( self._pre_population.label, self._post_population.label)) - return weights + return numpy.abs(weights) def _clip_delays(self, delays): """ Clip delay values, keeping track of how many have been clipped