sPyNNaker neural_modelling 7.3.1
Loading...
Searching...
No Matches
threshold_type_maass_stochastic.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
19#ifndef _THRESHOLD_TYPE_STOCHASTIC_H_
20#define _THRESHOLD_TYPE_STOCHASTIC_H_
21
22#include "threshold_type.h"
23#include <random.h>
24#include <stdfix-exp.h>
25
27#define PROB_SATURATION 0.8k
28
39};
40
42struct threshold_type_t {
53};
54
55// HACK: Needed to make some versions of gcc not mess up
56static volatile REAL ten = 10k;
57
58static void threshold_type_initialise(threshold_type_t *state, threshold_type_params_t *params,
59 uint32_t n_steps_per_timestep) {
60 REAL ts = kdivui(params->time_step_ms, n_steps_per_timestep);
61 state->du_th_inv = kdivk(ONE, params->du_th);
62 state->tau_th_inv = kdivk(ONE, params->tau_th);
63 state->v_thresh = params->v_thresh;
64 state->neg_machine_time_step_ms_div_10 = kdivk(ts, ten);
65}
66
67static void threshold_type_save_state(UNUSED threshold_type_t *state,
69}
70
76 state_t value, threshold_type_t *threshold_type) {
77 UREAL random_number = ukbits(mars_kiss64_simp() & 0xFFFF);
78
79 REAL exponent = (value - threshold_type->v_thresh)
80 * threshold_type->du_th_inv;
81
82 // if exponent is large, further calculation is unnecessary
83 // (result --> prob_saturation).
84 UREAL result;
85 if (exponent < 5.0k) {
86 REAL hazard = expk(exponent) * threshold_type->tau_th_inv;
87 result = (1.0k - expk(hazard *
88 threshold_type->neg_machine_time_step_ms_div_10)) *
90 } else {
91 result = PROB_SATURATION;
92 }
93
94 return REAL_COMPARE(result, >=, random_number);
95}
96
97#endif // _THRESHOLD_TYPE_STOCHASTIC_H_
#define ONE
A REAL 1.0.
Definition maths-util.h:119
unsigned accum UREAL
Type used for "unsigned real" numbers.
Definition maths-util.h:94
#define REAL_COMPARE(x, op, y)
Compare two REAL numbers.
Definition maths-util.h:192
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 state_t
The type of a state variable.
static uint n_steps_per_timestep
The number of steps to run per timestep.
uint32_t mars_kiss64_simp(void)
s1615 expk(s1615 x)
static stdp_params params
Configuration parameters.
API for threshold types.
static bool threshold_type_is_above_threshold(state_t value, threshold_type_t *threshold_type)
Determines if the value given is above the threshold value.
#define PROB_SATURATION
Probability of firing when at saturation.
REAL v_thresh
soft threshold value [mV]
REAL du_th
sensitivity of soft threshold to membrane voltage [mV-1]
REAL time_step_ms
time step scaling factor
REAL tau_th
time constant for soft threshold [ms-1]
REAL v_thresh
soft threshold value [mV]
REAL neg_machine_time_step_ms_div_10
time step scaling factor
Stochastic threshold parameters.
Stochastic threshold configuration.