Esempio n. 1
0
    def write_parameters(self, spec, machine_time_step, weight_scales):

        # Write alpha to spec
        fixed_point_alpha = plasticity_helpers.float_to_fixed(self.__alpha)
        spec.write_value(data=fixed_point_alpha, data_type=DataType.INT32)

        # Write lookup table
        spec.write_array(self.__tau_data)
Esempio n. 2
0
    def write_parameters(self, spec, machine_time_step, weight_scales):

        # Check timestep is valid
        if machine_time_step != 1000:
            raise NotImplementedError("STDP LUT generation currently only "
                                      "supports 1ms timesteps")

        # Write alpha to spec
        fixed_point_alpha = plasticity_helpers.float_to_fixed(
            self._alpha, plasticity_helpers.STDP_FIXED_POINT_ONE)
        spec.write_value(data=fixed_point_alpha, data_type=DataType.INT32)

        # Write lookup table
        plasticity_helpers.write_exp_lut(spec, self.tau, LOOKUP_TAU_SIZE,
                                         LOOKUP_TAU_SHIFT)
    def write_parameters(self, spec, machine_time_step, weight_scales):

        # Check timestep is valid
        if machine_time_step != 1000:
            raise NotImplementedError("STDP LUT generation currently only "
                                      "supports 1ms timesteps")

        # Write alpha to spec
        fixed_point_alpha = plasticity_helpers.float_to_fixed(
            self._alpha, plasticity_helpers.STDP_FIXED_POINT_ONE)
        spec.write_value(data=fixed_point_alpha, data_type=DataType.INT32)

        # Write lookup table
        plasticity_helpers.write_exp_lut(
            spec, self.tau, LOOKUP_TAU_SIZE, LOOKUP_TAU_SHIFT)
Esempio n. 4
0
    def write_parameters(self, spec, machine_time_step, weight_scales):
        # Write peak time in timesteps
        peak_time_data = int(self.peak_time * (1000.0 / machine_time_step) -
                             LOOKUP_SIN_SIZE / 2 + 0.5)
        print "peak time data:", peak_time_data, "peak_time:", self.peak_time
        spec.write_value(data=peak_time_data, data_type=DataType.INT32)

        # Calculate time constant reciprocal
        time_constant_reciprocal = (1.0 / float(self.tau)) * (
            machine_time_step / 1000.0)

        # This offset is the quasi-symmetry point
        sinadd_pwr = 20
        zero_offset = math.atan(-1. / sinadd_pwr)
        max_value = math.exp(-zero_offset) * math.cos(zero_offset)**sinadd_pwr

        # Generate LUT
        last_value = None
        for i in range(-LOOKUP_SIN_SIZE / 2,
                       -LOOKUP_SIN_SIZE / 2 + LOOKUP_SIN_SIZE):
            # Apply shift to get time from index
            time = (i << LOOKUP_SIN_SHIFT)

            # Multiply by time constant and calculate negative exponential
            value = float(time) * time_constant_reciprocal + zero_offset
            # we want a single bump only, so we clip the arg at pi/2
            if abs(value) > math.pi / 2.:
                exp_float = 0.0
            else:
                exp_float = math.exp(-value) * math.cos(
                    value)**sinadd_pwr / max_value
            print i, exp_float

            # Convert to fixed-point and write to spec
            last_value = plasticity_helpers.float_to_fixed(
                exp_float, plasticity_helpers.STDP_FIXED_POINT_ONE)
            spec.write_value(data=last_value, data_type=DataType.INT16)

        self._tau_last_entry = float(last_value) / float(
            plasticity_helpers.STDP_FIXED_POINT_ONE)