Modules | |
Basic_synapses | |
Sparse_synapses | |
Data Structures | |
struct | aspi_synapses_t |
Synaptic matrix structure. More... | |
struct | aspi_synapses_class_t |
Synapses class stucture. More... | |
Defines | |
#define | ASPI_SYNAPSES(x) (aspi_object_check (x, aspi_synapses ()), ((aspi_synapses_t *) x)) |
#define | ASPI_SYNAPSES_CLASS(x) (aspi_class_check (x, aspi_synapses ()), ((aspi_synapses_class_t *) x)) |
Functions | |
aspi_class_t * | aspi_synapses (void) |
void | aspi_synapses_dtor (aspi_object_t *self) |
aspi_object_t * | aspi_synapses_init (aspi_object_t *self, int n_neurons, double trace_leak) |
aspi_object_t * | aspi_synapses_init_generic (aspi_class_t *klass, aspi_object_t *self, int n_neurons, double trace_leak) |
int | aspi_synapses_get_size (aspi_object_t *self) |
double | aspi_synapses_get_trace_leak (aspi_object_t *self) |
double | aspi_synapses_get_weight (aspi_object_t *self, int pre, int post) |
void | aspi_synapses_set_weight (aspi_object_t *self, int pre, int post, double value) |
int | aspi_synapses_get_delay (aspi_object_t *self, int pre, int post) |
void | aspi_synapses_set_delay (aspi_object_t *self, int pre, int post, int value) |
double | aspi_synapses_get_trace (aspi_object_t *self, int pre, int post, int time) |
void | aspi_synapses_add_to_trace (aspi_object_t *self, int pre, int post, double value, int time) |
void | aspi_synapses_apply_callback_post (aspi_object_t *self, aspi_object_t *net, int neuron, aspi_callback_t callback, void *data) |
Apply a function to all synapses a neuron leads to. | |
void | aspi_synapses_apply_callback_pre (aspi_object_t *self, aspi_object_t *net, int neuron, aspi_callback_t callback, void *data) |
Apply a function to all synapses a neuron leads to. | |
void | aspi_synapses_apply_callback (aspi_object_t *self, aspi_object_t *net, aspi_callback_t callback, void *data) |
Apply a function to all synapses. |
This API is implemented by two classes: basic_synapses and sparse_synapses. The first one should take less memory in full matrixes, while the latter should be more efficient with sparse matrixes (< 2/3 weights = 0)
In order to use this matrix:
for (i = 0; i < aspi_synapses_get_size (mat); i++) { double * w = aspi_synapses_get_post_weights (mat, i); int * d = aspi_synapses_get_post_delays (mat, i); int * n = aspi_synapses_get_post_neurons (mat, i); for (j = 0; j < aspi_synapses_get_post_size (mat, i); j++) // do what you want with w[j] and d[j], and n[j] }
#define ASPI_SYNAPSES | ( | x | ) | (aspi_object_check (x, aspi_synapses ()), ((aspi_synapses_t *) x)) |
Referenced by aspi_synapses_get_size(), aspi_synapses_get_trace_leak(), and aspi_synapses_init().
#define ASPI_SYNAPSES_CLASS | ( | x | ) | (aspi_class_check (x, aspi_synapses ()), ((aspi_synapses_class_t *) x)) |
Referenced by aspi_basic_synapses(), aspi_sparse_synapses(), aspi_synapses_add_to_trace(), aspi_synapses_apply_callback(), aspi_synapses_apply_callback_post(), aspi_synapses_apply_callback_pre(), aspi_synapses_get_delay(), aspi_synapses_get_trace(), aspi_synapses_get_weight(), aspi_synapses_init_generic(), aspi_synapses_set_delay(), and aspi_synapses_set_weight().
aspi_class_t * aspi_synapses | ( | void | ) |
Get synapses class
References aspi_synapses_class_t::add_to_trace, aspi_synapses_class_t::apply_callback, aspi_synapses_class_t::apply_callback_post, aspi_synapses_class_t::apply_callback_pre, aspi_class_register(), aspi_object(), aspi_synapses_dtor(), aspi_synapses_init(), aspi_synapses_class_t::get_delay, aspi_synapses_class_t::get_trace, aspi_synapses_class_t::get_weight, _aspi_class::id, aspi_synapses_class_t::init, aspi_synapses_class_t::set_delay, and aspi_synapses_class_t::set_weight.
Referenced by aspi_basic_synapses(), aspi_sparse_synapses(), and aspi_synapses_init().
void aspi_synapses_add_to_trace | ( | aspi_object_t * | self, | |
int | pre, | |||
int | post, | |||
double | value, | |||
int | time | |||
) |
Update the synaptic trace with the current value
pre,: | presynaptic neuron (number) | |
post,: | postsynaptic neuron (number) | |
value,: | value |
References aspi_return_if_fail, and ASPI_SYNAPSES_CLASS.
void aspi_synapses_apply_callback | ( | aspi_object_t * | self, | |
aspi_object_t * | net, | |||
aspi_callback_t | callback, | |||
void * | data | |||
) |
Apply a function to all synapses.
Apply the callback function to every synapses. The order is not necessarily ascending.
References aspi_return_if_fail, and ASPI_SYNAPSES_CLASS.
void aspi_synapses_apply_callback_post | ( | aspi_object_t * | self, | |
aspi_object_t * | net, | |||
int | neuron, | |||
aspi_callback_t | callback, | |||
void * | data | |||
) |
Apply a function to all synapses a neuron leads to.
References aspi_return_if_fail, and ASPI_SYNAPSES_CLASS.
void aspi_synapses_apply_callback_pre | ( | aspi_object_t * | self, | |
aspi_object_t * | net, | |||
int | neuron, | |||
aspi_callback_t | callback, | |||
void * | data | |||
) |
Apply a function to all synapses a neuron leads to.
References aspi_return_if_fail, and ASPI_SYNAPSES_CLASS.
void aspi_synapses_dtor | ( | aspi_object_t * | self | ) |
Synapses destructor
References aspi_object_dtor().
Referenced by aspi_basic_synapses_dtor(), aspi_sparse_synapses_dtor(), and aspi_synapses().
int aspi_synapses_get_delay | ( | aspi_object_t * | self, | |
int | pre, | |||
int | post | |||
) |
Return a synaptic delay between two synapses
pre,: | presynaptic neuron (number) | |
post,: | postsynaptic neuron (number) |
References aspi_return_value_if_fail, and ASPI_SYNAPSES_CLASS.
Referenced by aspi_network_get_delay().
int aspi_synapses_get_size | ( | aspi_object_t * | self | ) |
Return matrix's size
self,: | the matrix |
References ASPI_SYNAPSES, and aspi_synapses_t::number_neurons.
Referenced by aspi_basic_synapses_add_to_trace(), aspi_basic_synapses_apply_callback(), aspi_basic_synapses_apply_callback_post(), aspi_basic_synapses_apply_callback_pre(), aspi_basic_synapses_get_delay(), aspi_basic_synapses_get_trace(), aspi_basic_synapses_get_weight(), aspi_basic_synapses_set_delay(), aspi_basic_synapses_set_weight(), aspi_sparse_synapses_apply_callback(), and aspi_sparse_synapses_dtor().
double aspi_synapses_get_trace | ( | aspi_object_t * | self, | |
int | pre, | |||
int | post, | |||
int | time | |||
) |
Return a synaptic trace between two synapses
pre,: | presynaptic neuron (number) | |
post,: | postsynaptic neuron (number) |
References aspi_return_value_if_fail, and ASPI_SYNAPSES_CLASS.
double aspi_synapses_get_trace_leak | ( | aspi_object_t * | self | ) |
Return the trace leak
References ASPI_SYNAPSES, and aspi_synapses_t::leak.
Referenced by aspi_basic_synapses_add_to_trace(), aspi_basic_synapses_get_trace(), aspi_sparse_synapses_add_to_trace(), and aspi_sparse_synapses_get_trace().
double aspi_synapses_get_weight | ( | aspi_object_t * | self, | |
int | pre, | |||
int | post | |||
) |
Return a synaptic weight between two synapses
pre,: | presynaptic neuron (number) | |
post,: | postsynaptic neuron (number) |
could be quite not good. Try
for (i = 0; i <= N; i++) { w = aspi_synapses_get_post_weight (syn, i); for (j = 0; j < aspi_synapses_get_post_size (syn, i); j++) ... }
References aspi_return_value_if_fail, and ASPI_SYNAPSES_CLASS.
Referenced by aspi_network_get_weight().
aspi_object_t * aspi_synapses_init | ( | aspi_object_t * | self, | |
int | n_neurons, | |||
double | trace_leak | |||
) |
Synapses initiazer
This create only a few things, and should be completed by derived classed.
This method should not be used directly, but rather aspi_synapses_init_generic or aspi_derived_synapses_init.
self,: | already alloced synapses or NULL | |
n_neurons,: | total number of neurons | |
trace_leak,: | -XXX or 0 to disable leak, or a number between 0 and 1 to set trace leak. Behaviour is undetermined if number > 1 Note on delays: there are no delays by default. They are created if necessary. If delays stay to zero, delays matrices stay NULL. |
References aspi_class_instantiate(), aspi_object_init(), ASPI_SYNAPSES, aspi_synapses(), aspi_synapses_t::leak, and aspi_synapses_t::number_neurons.
Referenced by aspi_basic_synapses_init(), aspi_sparse_synapses_init(), and aspi_synapses().
aspi_object_t * aspi_synapses_init_generic | ( | aspi_class_t * | klass, | |
aspi_object_t * | self, | |||
int | n_neurons, | |||
double | trace_leak | |||
) |
Generic initializer method
Call the init method of the class passed in parameter.
References aspi_return_value_if_fail, ASPI_SYNAPSES_CLASS, and aspi_synapses_class_t::init.
Referenced by aspi_network_init_full().
void aspi_synapses_set_delay | ( | aspi_object_t * | self, | |
int | pre, | |||
int | post, | |||
int | value | |||
) |
Set a synaptic delay between two synapses
pre,: | presynaptic neuron (number) | |
post,: | postsynaptic neuron (number) | |
value,: | value |
References aspi_return_if_fail, and ASPI_SYNAPSES_CLASS.
Referenced by aspi_network_set_delay().
void aspi_synapses_set_weight | ( | aspi_object_t * | self, | |
int | pre, | |||
int | post, | |||
double | value | |||
) |
Set a synaptic weight between two synapses
pre,: | presynaptic neuron (number) | |
post,: | postsynaptic neuron (number) | |
value,: | value |
References aspi_return_if_fail, and ASPI_SYNAPSES_CLASS.
Referenced by aspi_network_set_weight().