26 #ifndef SPARSECONNECTION_H_ 27 #define SPARSECONNECTION_H_ 40 #include <boost/random/mersenne_twister.hpp> 41 #include <boost/random/uniform_int.hpp> 42 #include <boost/random/uniform_real.hpp> 43 #include <boost/random/variate_generator.hpp> 44 #include <boost/random/exponential_distribution.hpp> 45 #include <boost/random/normal_distribution.hpp> 46 #include <boost/random/lognormal_distribution.hpp> 48 #define WARN_FILL_LEVEL 0.8 70 static bool has_been_seeded;
71 bool has_been_allocated;
73 bool init_from_file(
const char * filename);
75 AurynLong dryrun_from_file(
string filename);
121 std::vector<type_pattern>
load_pattern_file(
string filename,
int nb_max_patterns);
165 string name=
"SparseConnection");
181 string name=
"SparseConnection" 224 virtual void set(std::vector<neuron_pair> element_list,
AurynWeight value);
282 bool skip_diag=
false );
327 void load_patterns(
string filename,
AurynWeight strength,
int nb_max_patterns=10000,
bool overwrite =
false,
bool chainmode =
false);
AurynWeight get_max_weight()
Gets maximum weight (for plastic connections).
Definition: SparseConnection.h:420
AurynWeight wmax
Definition: SparseConnection.h:103
SparseConnection()
Empty constructor which should not be used – TODO should be deprecated at some point.
void set_block(NeuronID lo_row, NeuronID hi_row, NeuronID lo_col, NeuronID hi_col, AurynWeight weight)
Sets all weights of existing connections in a block spanned by the first 4 parameters to the value gi...
Definition: SparseConnection.cpp:307
void random_col_data(AurynWeight mean, AurynWeight sigma)
Sets weights in cols to the same value drewn from a Gaussian distribution.
Definition: SparseConnection.cpp:289
void load_pre_post_patterns(std::string pre_file, std::string post_file, AurynWeight strength, int nb_max_patterns=10000, bool overwrite=false)
Reads patterns from two files and connects them.
Definition: SparseConnection.cpp:1079
void set_upper_triangular(AurynWeight weight)
Sets weights in a upper triangular matrix.
Definition: SparseConnection.cpp:345
Standard Glutamatergic (excitatory) transmission.
Definition: auryn_definitions.h:139
void scale_block(NeuronID lo_row, NeuronID hi_row, NeuronID lo_col, NeuronID hi_col, AurynWeight alpha)
Scale all weights of existing connections in a block spanned by the first 4 parameters to the value g...
Definition: SparseConnection.cpp:321
bool skip_diagonal
Definition: SparseConnection.h:107
virtual void set_data(NeuronID i, AurynWeight value)
Sets weight value of a given element referenced by its index in the data array.
Definition: SparseConnection.cpp:661
The abstract base class for all Connection objects in Auryn.
Definition: Connection.h:53
std::vector< NeuronID > SpikeContainer
Spike container type. Used for storing spikes.
Definition: auryn_definitions.h:161
ForwardMatrix * w
A pointer that points per default to the ComplexMatrix that stores the connectinos.
Definition: SparseConnection.h:147
void seed(NeuronID randomseed)
This function seeds the pseudo random number generator for all random fill operatios.
Definition: SparseConnection.cpp:155
Abstract base class of all objects producing spikes.
Definition: SpikingGroup.h:67
void random_data_normal(AurynWeight mean, AurynWeight sigma)
Set weights of all existing connections randomly using a normal distrubtion.
Definition: SparseConnection.cpp:213
double AurynDouble
Higher precision floating point datatype.
Definition: auryn_definitions.h:158
virtual AurynWeight get_data(NeuronID i)
Returns weight value of a given element referenced by index in the data array.
Definition: SparseConnection.cpp:656
AurynFloat AurynWeight
Unit of synaptic weights.
Definition: auryn_definitions.h:159
bool patterns_ignore_gamma
Switch that toggles for the load_patterns function whether or not to use the intensity (gamma) value...
Definition: SparseConnection.h:126
AurynWeight wmin
Definition: SparseConnection.h:97
NeuronID patterns_every_post
The every_post parameter allows to skip postsynaptically over pattern IDs when loading patterns...
Definition: SparseConnection.h:138
virtual bool load_from_complete_file(string filename)
Loads weight matrix from a single file.
Definition: SparseConnection.cpp:921
The base class to create sparse random connections.
Definition: SparseConnection.h:66
bool push_back(NeuronID i, NeuronID j, AurynWeight weight)
Pushes a single element to the ComplexMatrix.
Definition: SparseConnection.cpp:515
std::vector< pattern_member > type_pattern
Definition: auryn_definitions.h:177
bool wrap_patterns
Switch that toggles the behavior when loading a pattern to wrap neuron IDs back onto existing cells v...
Definition: SparseConnection.h:143
Template for a sparse matrix with row major ordering and fast access of rows and capability to store ...
Definition: ComplexMatrix.h:75
virtual void clip(AurynWeight lo, AurynWeight hi)
Clip weights.
Definition: SparseConnection.cpp:1147
virtual void propagate()
Internally used propagate method.
Definition: SparseConnection.cpp:524
void connect_block_random(AurynWeight weight, AurynDouble sparseness, NeuronID lo_row, NeuronID hi_row, NeuronID lo_col, NeuronID hi_col, bool skip_diag=false)
Underlying sparse fill method.
Definition: SparseConnection.cpp:360
virtual void scale_all(AurynFloat value)
Scales all weights in the weight matrix with the given value.
Definition: SparseConnection.cpp:340
AurynLong estimate_required_nonzero_entires(AurynLong nonzero, double sigma=5.)
This function estimates the required size of the nonzero entry buffer.
Definition: SparseConnection.cpp:164
void sanity_check()
Quick an dirty function that checks if all units on the local rank are connected. ...
Definition: SparseConnection.cpp:537
Definition: ABSConnection.h:38
virtual void sparse_set_data(AurynDouble sparseness, AurynWeight value)
Sets a sparse random subset of connection elements wight the given value.
Definition: SparseConnection.cpp:271
unsigned long AurynLong
An unsigned long type used to count synapses or similar.
Definition: auryn_definitions.h:154
void init_random_binary(AurynFloat prob=0.5, AurynWeight wlo=0.0, AurynWeight whi=1.0)
Initialize with random binary at wlo and whi.
Definition: SparseConnection.cpp:250
virtual void virtual_serialize(boost::archive::binary_oarchive &ar, const unsigned int version)
Definition: Connection.h:71
virtual ~SparseConnection()
The default destructor.
Definition: SparseConnection.cpp:123
std::vector< neuron_pair > get_post_partners(NeuronID i)
Returns a vector of ConnectionsID of postsynaptic parterns of neuron i.
Definition: SparseConnection.cpp:1118
virtual void set_max_weight(AurynWeight maximum_weight)
Sets maximum weight (for plastic connections).
Definition: SparseConnection.cpp:203
virtual void set_all(AurynWeight weight)
Sets all weights of existing connections to the given value.
Definition: SparseConnection.cpp:335
void virtual_serialize(boost::archive::binary_oarchive &ar, const unsigned int version)
Definition: SparseConnection.h:78
AurynWeight get_min_weight()
Gets minimum weight (for plastic connections).
Definition: SparseConnection.h:412
virtual void stats(AurynDouble &mean, AurynDouble &std)
Computes mean and variance of weights in default weight matrix.
Definition: SparseConnection.cpp:618
void random_data(AurynWeight mean, AurynWeight sigma)
Synonym for random_data.
Definition: SparseConnection.cpp:208
void allocate_manually(AurynLong expected_size)
Is used whenever memory has to be allocated manually. Automatically adjusts for number of ranks and f...
Definition: SparseConnection.cpp:192
TransmitterType
Specifies the different transmitter types that Auryn knows.
Definition: auryn_definitions.h:138
float AurynFloat
Low precision floating point datatype.
Definition: auryn_definitions.h:157
void virtual_serialize(boost::archive::binary_iarchive &ar, const unsigned int version)
Definition: SparseConnection.h:84
NeuronID patterns_every_pre
The every_pre parameter allows to skip presynaptically over pattern IDs when loading patterns...
Definition: SparseConnection.h:132
virtual void set_min_weight(AurynWeight minimum_weight)
Sets minimum weight (for plastic connections).
Definition: SparseConnection.cpp:198
void allocate(AurynLong bufsize)
Definition: SparseConnection.cpp:175
void free()
Definition: SparseConnection.cpp:169
virtual bool load_from_file(string filename)
Loads weight matrix from Matrix Market (wmat) file.
Definition: SparseConnection.cpp:935
void load_patterns(string filename, AurynWeight strength, int nb_max_patterns=10000, bool overwrite=false, bool chainmode=false)
Reads first n patterns from a .pat file and adds them as Hebbian assemblies onto an existing weight m...
Definition: SparseConnection.cpp:1057
std::vector< neuron_pair > get_block(NeuronID lo_row, NeuronID hi_row, NeuronID lo_col, NeuronID hi_col)
Returns a vector of ConnectionsID of a block specified by the arguments.
Definition: SparseConnection.cpp:1100
AurynLong get_nonzero()
Returns number of nonzero elements in this SparseConnection.
Definition: SparseConnection.cpp:949
Abstract base class for all neuron groups.
Definition: NeuronGroup.h:45
void random_data_lognormal(AurynWeight m, AurynWeight s)
Set weights of all existing connections randomly using a lognormal distribution.
Definition: SparseConnection.cpp:231
static boost::mt19937 sparse_connection_gen
Definition: SparseConnection.h:91
virtual void finalize()
Finalizes connection after random or manual initialization of the weights.
Definition: SparseConnection.cpp:499
bool write_to_file(ForwardMatrix *m, string filename)
Writes rank specific weight matrix on the same rank to a file.
Definition: SparseConnection.cpp:690
void put_pattern(type_pattern *pattern, AurynWeight strength, bool overwrite)
Puts cell assembly to existing sparse weights.
Definition: SparseConnection.cpp:954
void connect_random(AurynWeight weight=1.0, AurynDouble sparseness=0.05, bool skip_diag=false)
Connect src and dst SpikingGroup and NeuronGroup randomly with given sparseness.
Definition: SparseConnection.cpp:487
virtual AurynWeight * get_ptr(NeuronID i, NeuronID j)
Returns pointer to given weight element if it exists. Returns NULL if element does not exist...
Definition: SparseConnection.cpp:671
virtual AurynDouble sum()
Computes sum of all weight elements in the Connection.
Definition: SparseConnection.cpp:645
std::string string
Standard library string type which is imported into Auryn namespace.
Definition: auryn_definitions.h:156
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
std::vector< neuron_pair > get_pre_partners(NeuronID j)
Returns a vector of ConnectionsID of presynaptic parterns of neuron i.
Definition: SparseConnection.cpp:1131
std::vector< type_pattern > load_pattern_file(string filename, int nb_max_patterns)
Reads patterns from a .pat file and returns a vector with the patterns.
Definition: SparseConnection.cpp:992
ComplexMatrix< AurynWeight > ForwardMatrix
Definition: SparseConnection.h:52