Example #1
0
    def convertWeight(self, w, synapse_type):
        if isinstance(w, list):
            w = numpy.array(w)
        if isinstance(w, RandomDistribution):
            weight = RandomDistribution(w.name, w.parameters, w.rng)
            if weight.name == "uniform":
                (w_min, w_max) = weight.parameters
                weight.parameters = (w_min, w_max)
            elif weight.name == "normal":
                (w_mean, w_std) = weight.parameters
                weight.parameters = (w_mean, w_std)
        else:
            weight = w

        if synapse_type == 'inhibitory':
            if isinstance(weight, RandomDistribution):
                if weight.name == "uniform":
                    myLogger.info(weight.name + ' ' + str(weight.parameters))
                    (w_min, w_max) = weight.parameters
                    if w_min >= 0 and w_max >= 0:
                        weight.parameters = (-w_max, -w_min)
                elif weight.name == "normal":
                    (w_mean, w_std) = weight.parameters
                    if w_mean > 0:
                        weight.parameters = (-w_mean, w_std)
                else:
                    myLogger.warn(
                        "No conversion of the inhibitory weights for this particular distribution"
                    )


#            elif weight > 0:
#weight *= -1
#                weight = weight
        return weight