reservoirpy.mat_gen.generate_internal_weights#

reservoirpy.mat_gen.generate_internal_weights = <reservoirpy.mat_gen.Initializer (_generate_internal_weights) object>[source]#
Generate the weight matrix that will be used for the internal connections of a

reservoir.

Warning

This function is deprecated since version v0.3.1 and will be removed in future versions. Please consider using normal(), uniform() or random_sparse() instead.

Parameters:
  • N (int, optional) – Shape \(N \times N\) of the array. This function only builds square matrices.

  • dist (str, default to "norm") – A distribution name from scipy.stats module, such as “norm” or “uniform”. Parameters like loc and scale can be passed to the distribution functions as keyword arguments to this function. Usual distributions for internal weights are scipy.stats.norm with parameters loc and scale to obtain weights following the standard normal distribution, or scipy.stats.uniform with parameters loc=-1 and scale=2 to obtain weights uniformly distributed between -1 and 1. Can also have the value “custom_bernoulli”. In that case, weights will be drawn from a Bernoulli discrete random variable alternating between -1 and 1 and drawing 1 with a probability p (default p parameter to 0.5).

  • connectivity (float, default to 0.1) – Also called density of the sparse matrix.

  • sr (float, optional) – If defined, then will rescale the spectral radius of the matrix to this value.

  • 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

  • **kwargs (optional) – Arguments for the scipy.stats distribution.

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