sPyNNaker neural_modelling  7.4.2
exp_synapse_utils.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 The University of Manchester
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
22 #include <stdfix-exp.h>
23 #include <neuron/decay.h>
24 
26 typedef struct exp_params_t {
31 } exp_params_t;
32 
34 typedef struct exp_state_t {
38 } exp_state_t;
39 
45 static inline void decay_and_init(exp_state_t *state, exp_params_t *params,
46  REAL time_step_ms, uint32_t n_steps_per_timestep) {
47  REAL ts = kdivui(time_step_ms, n_steps_per_timestep);
48  REAL ts_over_tau = kdivk(ts, params->tau);
49  decay_t decay = expulr(-ts_over_tau);
50  decay_t inv_decay = 1.0ulr - decay;
51  REAL tau_over_ts = kdivk(params->tau, ts);
52  decay_t init = decay_s1615_to_u032(tau_over_ts, inv_decay);
53  state->decay = decay;
54  state->init = init;
55  state->synaptic_input_value = params->init_input;
56 }
57 
60 static inline void exp_shaping(exp_state_t *exp_param) {
61  // decay value according to decay constant
62  exp_param->synaptic_input_value =
63  decay_s1615(exp_param->synaptic_input_value, exp_param->decay);
64 }
65 
70 static inline void add_input_exp(exp_state_t *parameter, input_t input) {
71  parameter->synaptic_input_value = parameter->synaptic_input_value +
72  decay_s1615(input, parameter->init);
73 }
utility method for decaying a value by a given amount
#define decay(x, d)
This is a type-generic decay "function".
Definition: decay.h:118
UFRACT decay_t
Definition: decay.h:44
static s1615 decay_s1615(s1615 x, decay_t decay)
this method takes a s1615 and decays it by a given amount (denoted by the decay) (to compensate for t...
Definition: decay.h:52
decay_t decay
Decay multiplier per timestep.
input_t synaptic_input_value
The actual synaptic contribution.
decay_t init
Initial decay factor.
static void decay_and_init(exp_state_t *state, exp_params_t *params, REAL time_step_ms, uint32_t n_steps_per_timestep)
Calculate the exponential state from the exponential parameters.
REAL tau
The decay time constant.
REAL init_input
The initial value.
static void exp_shaping(exp_state_t *exp_param)
Shapes a single parameter.
static void add_input_exp(exp_state_t *parameter, input_t input)
helper function to add input for a given timer period to a given neuron
The type of exponential decay parameters.
The type of exponential decay state.
accum REAL
Type used for "real" numbers.
Definition: maths-util.h:91
static REAL kdivk(REAL a, REAL b)
Divides an accum by another accum.
Definition: maths-util.h:234
static REAL kdivui(REAL a, uint32_t b)
Divides an accum by an unsigned integer.
Definition: maths-util.h:258
REAL input_t
The type of an input.
static uint n_steps_per_timestep
The number of steps to run per timestep.
static stdp_params params
Configuration parameters.