reservoirpy.mat_gen.fast_spectral_initialization#
- reservoirpy.mat_gen.fast_spectral_initialization = <reservoirpy.mat_gen.Initializer (_fast_spectral_initialization) object>[source]#
Fast spectral radius (FSI) approach for weights initialization [1] of square matrices.
This method is well suited for computation and rescaling of very large weights matrices, with a number of neurons typically above 500-1000.
- Parameters:
N (int, optional) – Shape \(N \times N\) of the array. This function only builds square matrices.
connectivity (float, default to 1.0) – Also called density of the sparse matrix. By default, creates dense arrays.
sr (float, optional) – If defined, then will rescale the spectral radius of the matrix to this value.
input_scaling (float or array, optional) – If defined, then will rescale the matrix using this coefficient or array of coefficients.
dtype (numpy.dtype, default to numpy.float64) – A Numpy numerical type.
sparsity_type ({"csr", "csc", "dense"}, default to "csr") – If connectivity is inferior to 1 and shape is only 2-dimensional, then the function will try to use one of the Scipy sparse matrix format (“csr” or “csc”). Else, a Numpy array (“dense”) will be used.
seed (optional) – Random generator seed. Default to the global value set with
reservoirpy.set_seed()
.degree (int, default to None) – If not None, override the connectivity argument and corresponds to the number of non-zero values along the axis specified by direction
direction ({"in", "out"}, default to "out") – If degree is not None, specifies the axis along which the degree non-zero values are distributed. - If direction is “in”, each line will have degree non-zero values. In other words, each node of the corresponding graph will have degree in-degrees - If direction is “out”, each column will have degree non-zero values. In other words, each node of the corresponding graph will have degree out-degrees
- Returns:
If a shape is given to the initializer, then returns a matrix. Else, returns a function partially initialized with the given keyword parameters, which can be called with a shape and returns a matrix.
- Return type:
Numpy array or callable
Note
This function was designed for initialization of a reservoir’s internal weights. In consequence, it can only produce square matrices. If more than one positional argument of shape are provided, only the first will be used.
References