reservoirpy.mat_gen.generate_input_weights#

reservoirpy.mat_gen.generate_input_weights = <reservoirpy.mat_gen.Initializer (_generate_input_weights) object>[source]#

Generate input or feedback weights for a reservoir.

Weights are drawn by default from a discrete Bernoulli random variable, i.e. are always equal to 1 or -1. Then, they can be rescaled to a specific constant using the input_scaling parameter.

Warning

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

Parameters:
  • N (int) – Number of units in the connected reservoir.

  • dim_input (int) – Dimension of the inputs connected to the reservoir.

  • 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.

  • input_scaling (float or array, optional) – If defined, then will rescale the matrix using this coefficient or array of coefficients.

  • input_bias (bool, optional) – ‘input_bias’ parameter is deprecated. Bias should be initialized separately from the input matrix. If True, will add a row to the matrix to take into account a constant bias added to the input.

  • 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