class brainpy.analysis.SlowPointFinder(f_cell, f_type=None, f_loss=None, verbose=True, args=(), inputs=None, t=None, dt=None, target_vars=None, excluded_vars=None, f_loss_batch=None, fun_inputs=None)[source]#

Find fixed/slow points by numerical optimization.

This class can help you:

  • optimize to find the closest fixed points / slow points

  • exclude any fixed points whose fixed point loss is above threshold

  • exclude any non-unique fixed points according to a tolerance

  • exclude any far-away “outlier” fixed points

  • f_cell (callable, function, DynamicalSystem) – The target of computing the recurrent units.

  • f_type (str) –

    The system’s type: continuous system or discrete system.

    • ’continuous’: continuous derivative function, denotes this is a continuous system, or

    • ’discrete’: discrete update function, denotes this is a discrete system.

  • verbose (bool) – Whether output the optimization progress.

  • f_loss (callable) –

    The loss function. - If f_type is “discrete”, the loss function must receive three

    arguments, i.e., loss(outputs, targets, axis).

    • If f_type is “continuous”, the loss function must receive two arguments, i.e., loss(outputs, axis).

    New in version 2.2.0.

  • t (float) –

    Parameter for f_cell is instance of DynamicalSystem. The time to evaluate the fixed points. Default is 0.

    New in version 2.2.0.

  • dt (float) –

    Parameter for f_cell is instance of DynamicalSystem. The numerical integration step, which can be used when . The default is given by brainpy.math.get_dt().

    New in version 2.2.0.

  • inputs (sequence, callable) –

    Parameter for f_cell is instance of DynamicalSystem. Same as inputs in DSRunner.

    New in version 2.2.0.

  • excluded_vars (sequence, dict) –

    Parameter for f_cell is instance of DynamicalSystem. The excluded variables (can be a sequence of Variable instances). These variables will not be included for optimization of fixed points.

    New in version 2.2.0.

  • target_vars (dict) –

    Parameter for f_cell is instance of DynamicalSystem. The target variables (can be a dict of Variable instances). These variables will be included for optimization of fixed points. The candidate points later provided should have same keys as in target_vars.

    New in version 2.2.0.

  • f_loss_batch (callable, function) –

    Parameter for f_cell is instance of DynamicalSystem. The function to compute the loss.

    Deprecated since version 2.2.0: Has been removed. Please use f_loss to set different loss function.

  • fun_inputs (callable) –

    Deprecated since version 2.3.1: Will be removed since version 2.4.0.

compute_jacobians(points, stack_dict_var=True, plot=False, num_col=4, len_col=3, len_row=2)[source]#

Compute the Jacobian matrices at the points.

  • points (np.ndarray, bm.ArrayType, jax.ndarray) – The fixed points with the shape of (num_point, num_dim).

  • stack_dict_var (bool) – Stack dictionary variables to calculate Jacobian matrix?

  • plot (bool) – Plot the decomposition results of the Jacobian matrix.

  • num_col (int) – The number of the figure column.

  • len_col (int) – The length of each column.

  • len_row (int) – The length of each row.

static decompose_eigenvalues(matrices, sort_by='magnitude', do_compute_lefts=False)[source]#

Compute the eigenvalues of the matrices.

  • matrices (np.ndarray, bm.ArrayType, jax.ndarray) – A 3D array with the shape of (num_matrices, dim, dim).

  • sort_by (str) – The method of sorting.

  • do_compute_lefts (bool) – Compute the left eigenvectors? Requires a pseudo-inverse call.


decompositions – A list of dictionaries with sorted eigenvalues components: (eigenvalues, right eigenvectors, and left eigenvectors).

Return type:



Exclude points whose closest neighbor is further than threshold.


tolerance (float) – Any point whose closest fixed point is greater than tol is an outlier.


Filter fixed points whose speed larger than a given tolerance.


tolerance (float) – Discard fixed points with squared speed larger than this value.

find_fps_with_gd_method(candidates, tolerance=1e-05, num_batch=100, num_opt=10000, optimizer=None)[source]#

Optimize fixed points with gradient descent methods.

  • candidates (ArrayType, dict) – The array with the shape of (batch size, state dim) of hidden states of RNN to start training for fixed points.

  • tolerance (float) – The loss threshold during optimization

  • num_opt (int) – The maximum number of optimization.

  • num_batch (int) – Print training information during optimization every so often.

  • optimizer (optim.Optimizer) –

    The optimizer instance.

    New in version 2.1.2.

find_fps_with_opt_solver(candidates, opt_solver='BFGS')[source]#

Optimize fixed points with nonlinear optimization solvers.

  • candidates (ArrayType, dict) – The candidate (initial) fixed points.

  • opt_solver (str) – The solver of the optimization.

property fixed_points: ndarray | Dict[str, ndarray]#

The final fixed points found.


Filter unique fixed points by choosing a representative within tolerance.


tolerance (float) – Tolerance for determination of identical fixed points.

property losses: ndarray#

Losses of fixed points.

property opt_losses: ndarray#

The optimization losses.

property selected_ids: ndarray#

The selected ids of candidate points.