Shared projections (either using the same set of weights for all post-synaptic neurons, or sharing its weight with another projection) are provided in the module ANNarchy.extensions.weightsharing
. They must be explicitely imported:
from ANNarchy import *
from ANNarchy.extensions.weightsharing import *
ANNarchy.extensions.weightsharing.
SharedProjection
(pre, post, target, psp='w * pre.r', operation='sum', name=None, copied=False)[source]¶Projection based on shared weights: each post-synaptic neuron uses the same weights, so they need to be instantiated only once to save memory.
Learning is not possible for now. The synapse
argument is removed, replaced by a single psp
argument to modified what is summed and operation
to replace the summation operation by max-pooling or similar..
Parameters:
Population
object).Population
object).w * pre.r
psp
(“sum”, “max”, “min”, “mean”). “sum” is the default.center
(*args, **kwds)[source]¶Returns the coordinates in the pre-synaptic population of the center of the kernel corresponding to the post-synaptic with the given rank or coordinates.
Parameters
connectivity_matrix
(fill=0.0)[source]¶Returns a dense connectivity matrix (2D Numpy array) representing the connections between the pre- and post-populations.
The first index of the matrix represents post-synaptic neurons, the second the pre-synaptic ones.
If PopulationViews were used for creating the projection, the matrix is expanded to the whole populations by default.
Parameters:
convolve
(weights, delays=0.0, method='convolution', keep_last_dimension=False, multiple=False, padding=0.0, subsampling=None)[source]¶Builds the shared connection pattern that will perform a convolution of the weights kernel on the pre-synaptic population.
Depending on the number of dimensions of the pre- and post-synaptic populations, as well as the kernel, the convolution can be implemented differentely.
keep_last_dimension
to True.weights
corresponds to the different filters, while the result will be accessible in the last dimension of the post-synaptic population. You must set the multiple
argument to True.Sub-sampling will be automatically performed according to the populations’ geometry. If these geometries do not match, an error will be thrown. You can force sub-sampling by providing a list subsampling
as argument, defining for each post-synaptic neuron the coordinates of the pre-synaptic neuron which will be the center of the filter/kernel.
Parameters:
copy
(projection)[source]¶Creates a virtual connection pattern reusing the weights and delays of an already-defined projection.
Although the original projection can be learnable, this one can not. Changes in the original weights will be reflected in this projection. The only possible modifications are psp
and operation
.
The pre- and post-synaptic populations of each projection must have the same geometry.
Parameters:
load
(filename)[source]¶Loads the saved state of the projection by Projection.save().
Warning: Matlab data can not be loaded.
Parameters:
Example:
proj.load('proj1.npz')
proj.load('proj1.txt')
proj.load('proj1.txt.gz')
pooling
(delays=0.0, extent=None, overlap=None)[source]¶Builds the shared connection pattern that will perform a pooling operation over the pre-synaptic population.
Each post-synaptic neuron is associated to a region of the pre-synaptic one, over which the result of the operation on firing rates will be assigned to sum(target).
If the SharedProjection does not define an operation, the default is “sum”. If you want max-pooling, you should set it to “max”.
Parameters:
receptive_fields
(variable='w', in_post_geometry=True)[source]¶Gathers all receptive fields within this projection.
Parameters:
save
(filename)[source]¶Saves all information about the projection (connectivity, current value of parameters and variables) into a file.
Parameter:
Warning
The ‘.mat’ data will not be loadable by ANNarchy, it is only for external analysis purpose.
Example:
proj.save('proj1.npz')
proj.save('proj1.txt')
proj.save('proj1.txt.gz')
proj.save('proj1.mat')
save_connectivity
(filename)[source]¶Saves the connectivity of the projection into a file.
Only the connectivity matrix, the weights and delays are saved, not the other synaptic variables.
The generated data can be used to create a projection in another network:
proj.connect_from_file(filename)
Parameters: