brainx-skill 1.0.15 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -1
- package/manifest.json +1 -1
- package/mcp-servers/codex/skills.json +1 -1
- package/package.json +1 -1
- package/skills/bio-neuro-lit/SKILL.md +4 -2
- package/skills/bio-neuro-lit/references/required-supplements.md +27 -0
- package/skills/brainx-acceleration/SKILL.md +30 -437
- package/skills/brainx-acceleration/references/audit-and-rewrite-patterns.md +326 -0
- package/skills/brainx-general-guard/SKILL.md +24 -8
- package/skills/brainx-install/SKILL.md +3 -3
- package/skills/brainx-install/references/compatibility-and-release-matching.md +28 -20
- package/skills/brainx-install/references/uninstall-and-cleanup.md +11 -4
- package/skills/brainx-modeling-loop/SKILL.md +117 -36
- package/skills/brainx-modeling-loop/agents/openai.yaml +2 -2
- package/skills/brainx-modeling-loop/references/mechanism-comparison.md +62 -0
- package/skills/brainx-modeling-loop/references/multiscale-coupling.md +16 -0
- package/skills/brainx-modeling-loop/references/paper-reproduction.md +42 -0
- package/skills/brainx-modeling-loop/references/parameter-fitting-workflow.md +14 -14
- package/skills/brainx-modeling-loop/references/run-experiment.md +1 -1
- package/skills/brainx-modeling-loop/references/training-workflow.md +10 -8
- package/skills/brainx-visualization/SKILL.md +6 -2
- package/skills/brainx-visualization/references/neural-data-visualization.md +1 -1
- package/skills/brainx-visualization/references/statistical-and-model-visualization.md +1 -1
- package/skills/package-skills/braincell/SKILL.md +23 -14
- package/skills/package-skills/braincell/references/braintools/input-current.md +1 -1
- package/skills/package-skills/braincell/references/braintools/metric.md +72 -46
- package/skills/package-skills/braincell/references/mixions-for-adaptation.md +1 -1
- package/skills/package-skills/braincell/references/multicompartment/braincell-manual-morphology-construction.md +1 -1
- package/skills/package-skills/braincell/references/multicompartment/cv-policy-reference.md +1 -1
- package/skills/package-skills/braincell/references/multicompartment/filter-function-library.md +3 -3
- package/skills/package-skills/braincell/references/multicompartment/morphology-io-loading-validation.md +1 -1
- package/skills/package-skills/braincell/references/multicompartment/multicompartment-cell-workflow.md +31 -43
- package/skills/package-skills/braincell/references/multicompartment/network-workflow.md +49 -0
- package/skills/package-skills/braincell/references/multicompartment/probe-reference.md +26 -114
- package/skills/package-skills/braincell/references/multicompartment/topology-building-and-visualization.md +40 -28
- package/skills/package-skills/braincell/references/scripts/cell_multicompartment_reference.py +13 -17
- package/skills/package-skills/brainevent/SKILL.md +0 -3
- package/skills/package-skills/brainevent/references/synaptic-plasticity.md +1 -1
- package/skills/package-skills/brainmass/SKILL.md +5 -3
- package/skills/package-skills/brainmass/references/brainstate/parameter-constraints-regularization.md +9 -7
- package/skills/package-skills/brainmass/references/brainstate/parameter-transforms-regularizers-catalog.md +4 -4
- package/skills/package-skills/brainmass/references/braintools/data-preprocessing.md +15 -7
- package/skills/package-skills/brainmass/references/braintools/metric.md +72 -46
- package/skills/package-skills/brainmass/references/coupling-network-api.md +3 -1
- package/skills/package-skills/brainmass/references/fitting-with-objectives-api.md +6 -6
- package/skills/package-skills/brainmass/references/horn-task-training.md +9 -9
- package/skills/package-skills/brainmass/references/modellibrary.md +12 -10
- package/skills/package-skills/brainmass/references/scripts/resting-state-meg-whole-brain-pipeline.py +5 -3
- package/skills/package-skills/brainmass/references/scripts/wilson-cowan-ei-dynamics.py +10 -6
- package/skills/package-skills/brainmass/references/simulator-input-monitor-api.md +3 -1
- package/skills/package-skills/brainmass/references/visualization-analysis-api.md +17 -9
- package/skills/package-skills/brainspike/SKILL.md +201 -0
- package/skills/package-skills/brainspike/references/braintools/connectivity.md +40 -0
- package/skills/package-skills/brainspike/references/braintools/data-preprocessing.md +39 -0
- package/skills/package-skills/brainspike/references/braintools/input-current.md +55 -0
- package/skills/package-skills/brainspike/references/braintools/metric.md +36 -0
- package/skills/package-skills/brainspike/references/braintools/optimizer.md +50 -0
- package/skills/package-skills/brainspike/references/braintools/parameter-initializer.md +43 -0
- package/skills/package-skills/brainspike/references/braintools/surrogate.md +40 -0
- package/skills/package-skills/brainspike/references/migration-boundary.md +38 -0
- package/skills/package-skills/brainspike/references/model-and-readout-selection.md +41 -0
- package/skills/package-skills/brainspike/references/multirate-coupling.md +31 -0
- package/skills/package-skills/brainspike/references/multiscale-composition.md +28 -0
- package/skills/package-skills/brainspike/references/native-composition.md +52 -0
- package/skills/package-skills/brainspike/references/native-delays.md +34 -0
- package/skills/package-skills/brainspike/references/native-projections.md +43 -0
- package/skills/package-skills/brainspike/references/native-training.md +36 -0
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/devices.md +33 -33
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/divergence-and-parity.md +15 -15
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/integration-categories.md +1 -1
- package/skills/package-skills/brainspike/references/nest-compatible/model-library.md +200 -0
- package/skills/package-skills/brainspike/references/nest-compatible/network-building.md +276 -0
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/brette_et_al_2007.py +23 -26
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/brunel_alpha.py +18 -21
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/brunel_delta.py +16 -19
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/clopath_synapse_spike_pairing.py +11 -12
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/evaluate_tsodyks2_synapse.py +10 -11
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/spatial_gaussex.py +18 -18
- package/skills/package-skills/{brainpy-state → brainspike}/references/nest-compatible/scripts/synapsecollection.py +26 -29
- package/skills/package-skills/brainspike/references/nest-compatible/synapse-and-connectivity.md +166 -0
- package/skills/package-skills/brainspike/references/nest-delay-boundaries.md +31 -0
- package/skills/package-skills/brainspike/references/nonlinear-state-sharing.md +26 -0
- package/skills/package-skills/{brainpy-state → brainspike}/references/perturbation-experiment-validity.md +2 -2
- package/skills/package-skills/brainspike/references/simulator-training.md +61 -0
- package/skills/package-skills/brainspike/references/temporal-task-training.md +36 -0
- package/skills/package-skills/brainspike/scripts/advanced_native_patterns.py +76 -0
- package/skills/package-skills/brainspike/scripts/delay_workflow.py +44 -0
- package/skills/package-skills/brainspike/scripts/delayed_cue_training.py +78 -0
- package/skills/package-skills/brainspike/scripts/lif_smoke.py +31 -0
- package/skills/package-skills/brainspike/scripts/multiscale_workflow.py +35 -0
- package/skills/package-skills/brainspike/scripts/native_ei_network.py +47 -0
- package/skills/package-skills/brainspike/scripts/native_workflows.py +77 -0
- package/skills/package-skills/brainspike/scripts/nest_boundary_workflows.py +108 -0
- package/skills/package-skills/brainspike/scripts/train_native_snn.py +65 -0
- package/skills/package-skills/brainspike/scripts/train_nest_simulator.py +69 -0
- package/skills/package-skills/brainspike/scripts/train_nest_simulator_two_weights.py +220 -0
- package/skills/package-skills/brainstate/SKILL.md +16 -21
- package/skills/package-skills/brainstate/references/brainstate/brainstate-control-flow-patterns.md +1 -138
- package/skills/package-skills/brainstate/references/brainstate/brainstate-transformed-diagnostics.md +1 -1
- package/skills/package-skills/brainstate/references/brainstate/delay-buffers.md +45 -0
- package/skills/package-skills/brainstate/references/brainstate/parameter-constraints-regularization.md +9 -7
- package/skills/package-skills/brainstate/references/brainstate/parameter-transforms-regularizers-catalog.md +4 -4
- package/skills/package-skills/brainstate/references/brainstate/randomness-and-reproducibility.md +6 -4
- package/skills/package-skills/brainstate/references/brainstate/transformation-grad-expansion.md +4 -4
- package/skills/package-skills/brainstate/references/brainstate/transformation-vmap-expansion.md +1 -1
- package/skills/package-skills/brainstate/references/braintools-optimizer-reference.md +16 -0
- package/skills/package-skills/brainstate/references/libraries/prebuilt-layer-library.md +1 -1
- package/skills/package-skills/brainstate/references/simulation-environment.md +5 -5
- package/skills/package-skills/braintrace/SKILL.md +17 -38
- package/skills/package-skills/braintrace/references/Drtrl.md +9 -26
- package/skills/package-skills/braintrace/references/algorithm selection.md +7 -12
- package/skills/package-skills/braintrace/references/batching.md +15 -35
- package/skills/package-skills/braintrace/references/compiler_internal.md +1 -1
- package/skills/package-skills/braintrace/references/custom algorithms.md +1 -2
- package/skills/package-skills/braintrace/references/customizing_primitive_transforms.md +26 -15
- package/skills/package-skills/braintrace/references/pp_pprop workflow.md +5 -139
- package/skills/package-skills/brainunit/SKILL.md +7 -2
- package/skills/package-skills/brainunit/references/array-mechanics/functional-structural-api.md +1 -1
- package/skills/package-skills/brainunit/references/math-function-library.md +2 -2
- package/skills/package-skills/brainunit/references/typing-and-runtime-validation.md +5 -2
- package/skills/package-skills/brainevent/references/scripts/102_EI_net_1996.py +0 -107
- package/skills/package-skills/brainevent/references/scripts/204_joglekar_2018_propagation.py +0 -168
- package/skills/package-skills/brainevent/references/scripts/coba_ei_teaching.py +0 -356
- package/skills/package-skills/brainpy-state/SKILL.md +0 -247
- package/skills/package-skills/brainpy-state/references/array-creation.md +0 -158
- package/skills/package-skills/brainpy-state/references/brain-dynamics-delay-protocol.md +0 -147
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/analysis.md +0 -150
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/brainpy legacy workflow.md +0 -373
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/built-in dynamic neuron model.md +0 -150
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/connecting neurons.md +0 -175
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/customize neuron and synpase.md +0 -286
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/Input generation.md +0 -111
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/More about simulation.md +0 -163
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/Multi-device array sharding.md +0 -113
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/Parallel experiment execution.md +0 -136
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/array creation and mechanics.md +0 -222
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/brainpy math environment setting.md +0 -123
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/delays.md +0 -107
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/infrastructure/object oriented transformations and control flows.md +0 -185
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/integrators.md +0 -181
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/route activity through connectivity.md +0 -102
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/synaptic projections.md +0 -147
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/synpase properties.md +0 -159
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/loss library.md +0 -127
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/optimizers.md +0 -167
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/parameter initializers.md +0 -107
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/prebuilt neural network layers.md +0 -186
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/surrogate gradients.md +0 -104
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/trainer library.md +0 -89
- package/skills/package-skills/brainpy-state/references/brainPy(legacy)/training/trainingworkflows.md +0 -253
- package/skills/package-skills/brainpy-state/references/braintools/brainstate-control-flow-patterns.md +0 -334
- package/skills/package-skills/brainpy-state/references/braintools/connectivity.md +0 -206
- package/skills/package-skills/brainpy-state/references/braintools/data-preprocessing.md +0 -79
- package/skills/package-skills/brainpy-state/references/braintools/input-current.md +0 -199
- package/skills/package-skills/brainpy-state/references/braintools/metric.md +0 -152
- package/skills/package-skills/brainpy-state/references/braintools/optimizer.md +0 -179
- package/skills/package-skills/brainpy-state/references/braintools/parameter-initializer.md +0 -183
- package/skills/package-skills/brainpy-state/references/braintools/surrogate.md +0 -147
- package/skills/package-skills/brainpy-state/references/component-selection.md +0 -288
- package/skills/package-skills/brainpy-state/references/nest-compatible/model-library.md +0 -200
- package/skills/package-skills/brainpy-state/references/nest-compatible/nest-workflow.md +0 -156
- package/skills/package-skills/brainpy-state/references/nest-compatible/network-building.md +0 -264
- package/skills/package-skills/brainpy-state/references/nest-compatible/synapse-and-connectivity.md +0 -153
- package/skills/package-skills/brainpy-state/references/projection-patterns.md +0 -127
- package/skills/package-skills/brainpy-state/references/scripts/103_COBA_2005.py +0 -86
- package/skills/package-skills/brainpy-state/references/scripts/106_COBA_HH_2007.py +0 -181
- package/skills/package-skills/brainpy-state/references/scripts/107_gamma_oscillation_1996.py +0 -156
- package/skills/package-skills/brainpy-state/references/scripts/109_fast_global_oscillation.py +0 -111
- package/skills/package-skills/brainpy-state/references/scripts/201_surrogate_grad_lif_fashion_mnist.py +0 -221
- package/skills/package-skills/brainpy-state/references/scripts/sound_localization.py +0 -240
- package/skills/package-skills/brainpy-state/references/scripts/training-snn.py +0 -119
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
# Array creation
|
|
2
|
-
|
|
3
|
-
Use this reference for specialized unit-aware ranges, grids, filled arrays, template-shaped arrays, matrix patterns, index constructors, and tree-shaped arrays. Basic `Quantity`, `asarray()`, and `arange()` construction remains in the parent skill.
|
|
4
|
-
|
|
5
|
-
```python
|
|
6
|
-
import brainunit as u
|
|
7
|
-
import jax.numpy as jnp
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
## Contents
|
|
11
|
-
|
|
12
|
-
- [Choose interval values](#choose-interval-values)
|
|
13
|
-
- [Build coordinate and power grids](#build-coordinate-and-power-grids)
|
|
14
|
-
- [Fill a new shape](#fill-a-new-shape)
|
|
15
|
-
- [Follow an existing shape](#follow-an-existing-shape)
|
|
16
|
-
- [Build matrices and masks](#build-matrices-and-masks)
|
|
17
|
-
- [Locate triangular entries](#locate-triangular-entries)
|
|
18
|
-
- [Mirror pytrees](#mirror-pytrees)
|
|
19
|
-
- [Convert NumPy input](#convert-numpy-input)
|
|
20
|
-
- [Routing](#routing)
|
|
21
|
-
- [Cross-family gotchas](#cross-family-gotchas)
|
|
22
|
-
- [Sources mirrored](#sources-mirrored)
|
|
23
|
-
|
|
24
|
-
## Choose interval values
|
|
25
|
-
|
|
26
|
-
### `linspace`
|
|
27
|
-
|
|
28
|
-
| Exact signature | Use when | One-line description | Code and result |
|
|
29
|
-
|---|---|---|---|
|
|
30
|
-
| `linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None)` | Generate a fixed number of evenly spaced samples between two endpoints. | Return evenly spaced numbers over a specified interval. | `u.math.linspace(0 * u.second, 10 * u.second, 5)`<br>`# Quantity([ 0. 2.5 5. 7.5 10. ], "s")` |
|
|
31
|
-
|
|
32
|
-
### `logspace`
|
|
33
|
-
|
|
34
|
-
| Exact signature | Use when | One-line description | Code and result |
|
|
35
|
-
|---|---|---|---|
|
|
36
|
-
| `logspace(start, stop, num=50, endpoint=True, base=10.0, dtype=None)` | Generate values whose exponents are evenly spaced. | Return numbers spaced evenly on a log scale. | `u.math.logspace(0, 2, 3)`<br>`# Array([ 1., 10., 100.], dtype=float32)` |
|
|
37
|
-
|
|
38
|
-
## Build coordinate and power grids
|
|
39
|
-
|
|
40
|
-
### `meshgrid`
|
|
41
|
-
|
|
42
|
-
| Exact signature | Use when | One-line description | Code and result |
|
|
43
|
-
|---|---|---|---|
|
|
44
|
-
| `meshgrid(*xi, copy=True, sparse=False, indexing='xy')` | Expand 1-D coordinate vectors into dense or sparse coordinate grids. | Return coordinate matrices from coordinate vectors. | `x = jnp.array([1, 2]) * u.meter; t = jnp.array([0, 1, 2]) * u.second; x_grid, t_grid = u.math.meshgrid(x, t, indexing='ij')`<br>`# both shapes: (2, 3); units: meter and second` |
|
|
45
|
-
|
|
46
|
-
### `vander`
|
|
47
|
-
|
|
48
|
-
| Exact signature | Use when | One-line description | Code and result |
|
|
49
|
-
|---|---|---|---|
|
|
50
|
-
| `vander(x, N=None, increasing=False, unit=Unit('1'))` | Build a Vandermonde matrix from powers of a 1-D vector. | Generate a Vandermonde matrix. | `u.math.vander(jnp.array([1, 2]), N=3)`<br>`# Array([[1, 1, 1], [4, 2, 1]], dtype=int32)` |
|
|
51
|
-
|
|
52
|
-
## Fill a new shape
|
|
53
|
-
|
|
54
|
-
### Initialized arrays
|
|
55
|
-
|
|
56
|
-
| API | Description & result |
|
|
57
|
-
|---|---|
|
|
58
|
-
| `full(shape, fill_value, dtype=None)` | Fill a new shape with `fill_value`; a quantity fill produces a `Quantity` with that unit.<br>`u.math.full(2, 3 * u.second)`<br>`# Quantity([3, 3], "s")` |
|
|
59
|
-
| `ones(shape, dtype=None, unit=Unit('1'))` | Fill a new shape with ones. Returns a plain JAX array by default or a `Quantity` when a non-trivial unit is supplied.<br>`u.math.ones(2, unit=u.second)`<br>`# Quantity([1., 1.], "s")` |
|
|
60
|
-
| `zeros(shape, dtype=None, unit=Unit('1'))` | Fill a new shape with zeros. Returns a plain JAX array by default or a `Quantity` when a non-trivial unit is supplied.<br>`u.math.zeros(2)`<br>`# plain JAX array` |
|
|
61
|
-
|
|
62
|
-
### `empty`
|
|
63
|
-
|
|
64
|
-
| Exact signature | Use when | One-line description | Code and result |
|
|
65
|
-
|---|---|---|---|
|
|
66
|
-
| `empty(shape, dtype=None, unit=Unit('1'))` | Allocate a shape when every entry will be overwritten before it is read. | Return a new quantity or array of given shape and type, without initializing entries. | `buffer = u.math.empty((2, 2), unit=u.second); buffer.shape`<br>`# (2, 2); entry values are unspecified` |
|
|
67
|
-
|
|
68
|
-
## Follow an existing shape
|
|
69
|
-
|
|
70
|
-
### `full_like`
|
|
71
|
-
|
|
72
|
-
| Exact signature | Use when | One-line description | Code and result |
|
|
73
|
-
|---|---|---|---|
|
|
74
|
-
| `full_like(a, fill_value, dtype=None, shape=None)` | Fill an array using a prototype's shape and dtype. | Return a new quantity or array with the same shape and type as a given array or quantity, filled with `fill_value`. | `prototype = jnp.zeros(2) * u.second; u.math.full_like(prototype, 500 * u.ms)`<br>`# Quantity([0.5 0.5], "s")` |
|
|
75
|
-
|
|
76
|
-
### `empty_like`
|
|
77
|
-
|
|
78
|
-
| Exact signature | Use when | One-line description | Code and result |
|
|
79
|
-
|---|---|---|---|
|
|
80
|
-
| `empty_like(prototype, dtype=None, shape=None, unit=Unit('1'))` | Allocate an uninitialized buffer shaped and typed like a prototype. | Return a new quantity or array with the same shape and type as a given array. | `prototype = jnp.ones(3) * u.second; buffer = u.math.empty_like(prototype); buffer.shape`<br>`# (3,); unit: second; entry values are unspecified` |
|
|
81
|
-
|
|
82
|
-
### Create one or zero arrays
|
|
83
|
-
|
|
84
|
-
| API | Description & result |
|
|
85
|
-
|---|---|
|
|
86
|
-
| `ones_like(a, dtype=None, shape=None, unit=Unit('1'))` | Create ones with `a`'s shape and dtype. A `Quantity` prototype preserves its unit by default; a non-trivial `unit` attaches a unit to a plain prototype or requests a compatible conversion. |
|
|
87
|
-
| `zeros_like(a, dtype=None, shape=None, unit=Unit('1'))` | Create zeros with `a`'s shape and dtype. A `Quantity` prototype preserves its unit by default; a non-trivial `unit` attaches a unit to a plain prototype or requests a compatible conversion. |
|
|
88
|
-
|
|
89
|
-
## Build matrices and masks
|
|
90
|
-
|
|
91
|
-
### Identity-like and triangular constructors
|
|
92
|
-
|
|
93
|
-
| API | Description & result |
|
|
94
|
-
|---|---|
|
|
95
|
-
| `eye(N, M=None, k=0, dtype=None, unit=Unit('1'))` | Create an `N`-by-`M` array with ones on diagonal `k` and zeros elsewhere. Returns a plain JAX array by default or a `Quantity` with a non-trivial unit. |
|
|
96
|
-
| `identity(n, dtype=None, unit=Unit('1'))` | Create an `n`-by-`n` identity array. Returns a plain JAX array by default or a `Quantity` with a non-trivial unit. |
|
|
97
|
-
| `tri(N, M=None, k=0, dtype=None, unit=Unit('1'))` | Create an `N`-by-`M` array with ones at and below diagonal `k`. Returns a plain JAX array by default or a `Quantity` with a non-trivial unit. |
|
|
98
|
-
|
|
99
|
-
### `diag`
|
|
100
|
-
|
|
101
|
-
| Exact signature | Use when | One-line description | Code and result |
|
|
102
|
-
|---|---|---|---|
|
|
103
|
-
| `diag(v, k=0, unit=Unit('1'))` | Construct a diagonal matrix or extract a diagonal based on input rank. | Extract a diagonal or construct a diagonal array. | `vector = jnp.array([1, 2, 3]) * u.second; matrix = u.math.diag(vector); extracted = u.math.diag(matrix); (matrix.shape, extracted.shape)`<br>`# ((3, 3), (3,))` |
|
|
104
|
-
|
|
105
|
-
### Keep one triangle of an existing array
|
|
106
|
-
|
|
107
|
-
| API | Description & result |
|
|
108
|
-
|---|---|
|
|
109
|
-
| `tril(m, k=0, unit=Unit('1'))` | Return `m` with entries above diagonal `k` zeroed, applying to the final two axes when `m.ndim > 2`. It preserves a `Quantity` input's unit by default; `unit` can attach or request a compatible output unit.<br>`m = jnp.arange(1, 5).reshape(2, 2); u.math.tril(m)`<br>`# [[1, 0], [3, 4]]` |
|
|
110
|
-
| `triu(m, k=0, unit=Unit('1'))` | Return `m` with entries below diagonal `k` zeroed, applying to the final two axes when `m.ndim > 2`. It preserves a `Quantity` input's unit by default; `unit` can attach or request a compatible output unit.<br>`m = jnp.arange(1, 5).reshape(2, 2); u.math.triu(m)`<br>`# [[1, 2], [0, 4]]` |
|
|
111
|
-
|
|
112
|
-
### `fill_diagonal`
|
|
113
|
-
|
|
114
|
-
| Exact signature | Use when | One-line description | Code and result |
|
|
115
|
-
|---|---|---|---|
|
|
116
|
-
| `fill_diagonal(a, val, wrap=False, inplace=False)` | Replace the main diagonal of an existing array with one value. | Fill the main diagonal of the given array of any dimensionality. | `q = jnp.zeros((2, 2)) * u.second; filled = u.math.fill_diagonal(q, 500 * u.ms)`<br>`# Quantity([[0.5 0. ] [0. 0.5]], "s")` |
|
|
117
|
-
|
|
118
|
-
## Locate triangular entries
|
|
119
|
-
|
|
120
|
-
### Lower and upper triangle indices
|
|
121
|
-
|
|
122
|
-
| API | Description & result |
|
|
123
|
-
|---|---|
|
|
124
|
-
| `tril_indices(n, k=0, m=None)` | Return row and column indices for the lower triangle of an `(n, m)` array as two plain integer arrays. |
|
|
125
|
-
| `triu_indices(n, k=0, m=None)` | Return row and column indices for the upper triangle of an `(n, m)` array as two plain integer arrays. |
|
|
126
|
-
| `tril_indices_from(arr, k=0)` | Derive lower-triangle row and column indices from a 2-D array's shape. Returns two plain integer arrays; an input `Quantity` does not give the indices a unit. |
|
|
127
|
-
| `triu_indices_from(arr, k=0)` | Derive upper-triangle row and column indices from a 2-D array's shape. Returns two plain integer arrays; an input `Quantity` does not give the indices a unit. |
|
|
128
|
-
|
|
129
|
-
## Mirror pytrees
|
|
130
|
-
|
|
131
|
-
### One or zero in every leaf
|
|
132
|
-
|
|
133
|
-
| API | Description & result |
|
|
134
|
-
|---|---|
|
|
135
|
-
| `tree_ones_like(tree)` | Replace every pytree leaf with ones while preserving structure, leaf shape, dtype, and unit; plain leaves remain plain and quantity leaves remain quantities. |
|
|
136
|
-
| `tree_zeros_like(tree)` | Replace every pytree leaf with zeros while preserving structure, leaf shape, dtype, and unit; plain leaves remain plain and quantity leaves remain quantities. |
|
|
137
|
-
|
|
138
|
-
## Convert NumPy input
|
|
139
|
-
|
|
140
|
-
| API | Description & result |
|
|
141
|
-
|---|---|
|
|
142
|
-
| `from_numpy(x, unit=Unit('1'))` | Convert a NumPy array to the JAX backend. Returns a plain JAX array by default or a `Quantity` with the supplied non-trivial unit. |
|
|
143
|
-
|
|
144
|
-
## Routing
|
|
145
|
-
|
|
146
|
-
`array_split()` appears on the tutorial page, but it is a structural operation; route it to `array-mechanics.md`.
|
|
147
|
-
|
|
148
|
-
Backend extraction and `as_numpy()` belong in `array-mechanics.md` because they cross an existing array boundary rather than create a scientific quantity from source values.
|
|
149
|
-
|
|
150
|
-
## Cross-family gotchas
|
|
151
|
-
|
|
152
|
-
- For constructors with `unit=Unit('1')`, the unitless default produces a plain JAX array unless a quantity input supplies a unit; pass a non-trivial `Unit` to request a `Quantity`.
|
|
153
|
-
- The `dtype` and `shape` arguments on `*_like` functions override the prototype; otherwise its dtype and shape are retained.
|
|
154
|
-
|
|
155
|
-
## Sources mirrored
|
|
156
|
-
|
|
157
|
-
- https://brainx.chaobrain.com/brainunit/unit_operations/array_creation.html
|
|
158
|
-
- https://brainx.chaobrain.com/brainunit/apis/brainunit.math.html
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
# BrainPy projection delay protocol
|
|
2
|
-
|
|
3
|
-
Use this reference after choosing a native `brainpy.state` projection when presynaptic spikes or continuous values must reach the target after an axonal or synaptic transmission delay. This reference owns BrainPy projection integration; use the general BrainState delay protocol for arbitrary history buffers, named delay taps, delayed feedback State, or manual retrieval.
|
|
4
|
-
|
|
5
|
-
## Choose the delay integration point
|
|
6
|
-
|
|
7
|
-
Delay the signal before communication. Choose the API from how the projection receives that signal:
|
|
8
|
-
|
|
9
|
-
| Signal path | Use when | Call contract |
|
|
10
|
-
|---|---|---|
|
|
11
|
-
| `AlignPostProj(..., delay=delay)` | The step pushes a spike/event array directly into an AlignPost projection. | Call `proj(signal)`; the projection delays the supplied presynaptic input before `comm`. |
|
|
12
|
-
| `CurrentProj(..., delay=delay)` | The step pushes a continuous presynaptic value through communication and output conversion without synaptic dynamics. | Call `proj(signal)`; the projection delays the supplied value before `comm`. |
|
|
13
|
-
| `pre.prefetch("V").delay.at(delay)` | The projection pulls from a built-in neuron, which stores membrane potential rather than a separate historical spike State. | Build the projection once with the delayed prefetch and a spike decoder, then call `proj()` with no explicit signal. |
|
|
14
|
-
| General `brainstate.nn.Delay` APIs | The task needs reusable buffers, multiple named taps, manual updates, step-based retrieval, round interpolation, or custom delayed State. | Leave the BrainPy projection path and use the general BrainState protocol. |
|
|
15
|
-
|
|
16
|
-
Do not combine a delayed prefetch with an explicit signal at update time. The projection either pulls its configured delayed source or delays the value passed to `proj(signal)`.
|
|
17
|
-
|
|
18
|
-
## Push a delayed signal
|
|
19
|
-
|
|
20
|
-
Use `delay=` for a direct-input `AlignPostProj` or `CurrentProj`. A scalar time applies one homogeneous delay; an `(N_pre,)` quantity applies one delay per presynaptic neuron.
|
|
21
|
-
|
|
22
|
-
| API | Behavior |
|
|
23
|
-
|---|---|
|
|
24
|
-
| `AlignPostProj(..., delay=None)` | Keep the zero-overhead undelayed path. |
|
|
25
|
-
| `AlignPostProj(..., delay=scalar_time)` | Delay every presynaptic element by the same duration. |
|
|
26
|
-
| `AlignPostProj(..., delay=per_pre_time)` | Apply heterogeneous axonal delays; the delay array must have shape `(N_pre,)`. |
|
|
27
|
-
| `CurrentProj(..., delay=...)` | Apply the same scalar or per-presynaptic delay contract to continuous direct input. |
|
|
28
|
-
|
|
29
|
-
```python
|
|
30
|
-
proj = brainpy.state.AlignPostProj(
|
|
31
|
-
comm=brainstate.nn.EventFixedProb(
|
|
32
|
-
n_pre,
|
|
33
|
-
n_post,
|
|
34
|
-
conn_num=0.1,
|
|
35
|
-
conn_weight=0.5 * u.mS,
|
|
36
|
-
),
|
|
37
|
-
syn=brainpy.state.Expon.desc(n_post, tau=5.0 * u.ms),
|
|
38
|
-
out=brainpy.state.COBA.desc(E=0.0 * u.mV),
|
|
39
|
-
post=post,
|
|
40
|
-
delay=5.0 * u.ms,
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
# Inside the step, before post(...) integrates:
|
|
44
|
-
proj(pre.get_spike() != 0.0)
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
Sub-`dt` delays are linearly interpolated. `init_state()` sizes the buffer from `ceil(max(delay) / dt)`, so establish `dt` before State initialization and do not change it during that initialized run.
|
|
48
|
-
|
|
49
|
-
## Pull a delayed neuron signal
|
|
50
|
-
|
|
51
|
-
Use delayed prefetch when the projection owns presynaptic extraction. Built-in neurons expose historical `V`, not a separate stored spike history, so delay `V` and re-derive the spike from the delayed voltage.
|
|
52
|
-
|
|
53
|
-
```python
|
|
54
|
-
proj = brainpy.state.AlignPostProj(
|
|
55
|
-
pre.prefetch("V").delay.at(5.0 * u.ms),
|
|
56
|
-
lambda voltage: pre.get_spike(voltage) != 0.0,
|
|
57
|
-
comm=brainstate.nn.EventFixedProb(
|
|
58
|
-
n_pre,
|
|
59
|
-
n_post,
|
|
60
|
-
conn_num=0.1,
|
|
61
|
-
conn_weight=0.5 * u.mS,
|
|
62
|
-
),
|
|
63
|
-
syn=brainpy.state.Expon.desc(n_post, tau=5.0 * u.ms),
|
|
64
|
-
out=brainpy.state.COBA.desc(E=0.0 * u.mV),
|
|
65
|
-
post=post,
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
# The projection pulls the delayed voltage and decodes its spike.
|
|
69
|
-
proj()
|
|
70
|
-
pre(drive)
|
|
71
|
-
post(0.0 * u.mA)
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
Keep the projection-before-post order. The delayed signal must be communicated before `post(...)` integrates the current step.
|
|
75
|
-
|
|
76
|
-
## Initialize, reset, and verify
|
|
77
|
-
|
|
78
|
-
1. Enter `brainstate.environ.context(dt=...)`.
|
|
79
|
-
2. Construct the network and delay-bearing projection.
|
|
80
|
-
3. Call `brainstate.nn.init_all_states(net)` so neural State and delay buffers are initialized together.
|
|
81
|
-
4. Run time through `brainstate.transform.for_loop`.
|
|
82
|
-
5. For every independent rollout, call `init_all_states()` again.
|
|
83
|
-
6. Compare otherwise identical undelayed, short-delay, and long-delay runs; monitor the presynaptic spike and projection conductance/current to verify the expected arrival-time shift before interpreting postsynaptic spikes.
|
|
84
|
-
|
|
85
|
-
Do not validate a delay only from postsynaptic spike time. Membrane integration, thresholding, refractory State, and other inputs can shift or suppress the postsynaptic spike even when the transmission delay is correct.
|
|
86
|
-
|
|
87
|
-
## Use a manual BrainState delay
|
|
88
|
-
|
|
89
|
-
Insert the current sample before retrieval so step 0 always means current and step `d` means exactly `d` completed updates earlier.
|
|
90
|
-
|
|
91
|
-
| API | Description |
|
|
92
|
-
|---|---|
|
|
93
|
-
| `brainstate.nn.Delay(target_info, max_time)` | Use when model logic needs an explicit reusable history buffer rather than a projection-owned delay; it allocates enough history for `max_time` under the initialization `dt`. |
|
|
94
|
-
| `delay.update(value)` | Insert the current sample once per step before any retrieval that should include the updated history. |
|
|
95
|
-
| `delay.retrieve_at_step(step)` | Retrieve an integer-offset sample; after the current update, step 0 is `value` and step `d` is the value from `d` updates earlier. |
|
|
96
|
-
| `delay.retrieve_at_time(time)` | Retrieve by a unit-bearing time when the model is defined in physical time; select the documented interpolation behavior rather than manually rounding an off-grid delay. |
|
|
97
|
-
| `delay.register_entry(name, vector_delays, indices)` and `delay.at(name)` | Use for one named heterogeneous tap per selected source element; register before State initialization, then retrieve the selected delayed values after each update. |
|
|
98
|
-
|
|
99
|
-
```python
|
|
100
|
-
import brainstate
|
|
101
|
-
import brainunit as u
|
|
102
|
-
import jax
|
|
103
|
-
import jax.numpy as jnp
|
|
104
|
-
|
|
105
|
-
with brainstate.environ.context(dt=1.0 * u.ms):
|
|
106
|
-
delay = brainstate.nn.Delay(
|
|
107
|
-
jax.ShapeDtypeStruct((), jnp.float32),
|
|
108
|
-
3.0 * u.ms,
|
|
109
|
-
)
|
|
110
|
-
brainstate.nn.init_all_states(delay)
|
|
111
|
-
impulse = jnp.array([1.0, 0.0, 0.0, 0.0, 0.0])
|
|
112
|
-
|
|
113
|
-
def step(value):
|
|
114
|
-
delay.update(value)
|
|
115
|
-
return delay.retrieve_at_step(jnp.asarray(3, dtype=jnp.int32))
|
|
116
|
-
|
|
117
|
-
delayed = brainstate.transform.for_loop(step, impulse)
|
|
118
|
-
|
|
119
|
-
assert jnp.array_equal(delayed, jnp.array([0.0, 0.0, 0.0, 1.0, 0.0]))
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
If retrieval occurs before `update(value)`, the buffer still represents the previous completed step and the index for the same observed latency changes by one. Do not compensate with an unexplained `d - 1`; choose one call order, document it beside the step, and lock the convention with an impulse assertion before interpreting neural output.
|
|
123
|
-
|
|
124
|
-
Reinitialize the delay for every independent rollout. A silent input interval advances the buffer but does not establish an independent State lifecycle.
|
|
125
|
-
|
|
126
|
-
For grid-aligned binary spikes, retrieve exact integer steps or use named entries whose delays are integer multiples of `dt`. Linear time interpolation can produce fractional numeric values, which no longer satisfy binary-event semantics. Use continuous interpolation only when the modeled signal and off-grid timing require it.
|
|
127
|
-
|
|
128
|
-
When a unit-bearing event time feeds an integer delay bank, convert `time / dt` to one documented integer step before the rollout and generate the event on that grid. Do not rediscover its step inside the time loop with a half-open `abs(t - arrival) < dt / 2` window; exact half-step results can depend on floating representation.
|
|
129
|
-
|
|
130
|
-
## Map delay State across independent conditions
|
|
131
|
-
|
|
132
|
-
Keep every writable part of a delay on one compatible mapped axis. A ring buffer whose history is per lane but whose mutable write pointer remains scalar cannot be shared across a mapped step, even when every lane advances in lockstep.
|
|
133
|
-
|
|
134
|
-
Prefer `brainstate.nn.Delay` when its complete mutable State can be initialized and mapped per condition. If its bookkeeping cannot satisfy the State-axis policy, use a small pointer-free `HiddenState` shift register only for a fixed integer delay bank; keep step 0 as the current event and prove at least one nonzero tap with an impulse assertion. Do not generalize this fallback to long histories because shifting the full buffer costs work proportional to the maximum delay.
|
|
135
|
-
|
|
136
|
-
Open `references/scripts/sound_localization.py` when building a mapped multi-tap coincidence detector, for the verified pointer-free fallback, semantic State filters, integer event taps, and impulse check.
|
|
137
|
-
|
|
138
|
-
## General BrainState boundary
|
|
139
|
-
|
|
140
|
-
Open the official BrainState [Delay Protocol](https://brainx.chaobrain.com/brainstate/tutorials/brain_dynamics/02_synaptic_delays.html) when implementing `brainstate.nn.DelayAccess`, `brainstate.nn.StateWithDelay`, rotation versus concatenation buffers, named entries, multiple taps, or linear-versus-round interpolation. Those mechanisms are more general than BrainPy projection delays and should not be reconstructed inside a projection unless the projection APIs cannot express the required history.
|
|
141
|
-
|
|
142
|
-
## Official sources
|
|
143
|
-
|
|
144
|
-
- `https://brainx.chaobrain.com/brainpy-state/brainpy-style/howto/sim-delays.html`
|
|
145
|
-
- `https://brainx.chaobrain.com/brainpy-state/apis/generated/brainpy.state.AlignPostProj.html`
|
|
146
|
-
- `https://brainx.chaobrain.com/brainpy-state/apis/generated/brainpy.state.CurrentProj.html`
|
|
147
|
-
- `https://brainx.chaobrain.com/brainstate/tutorials/brain_dynamics/02_synaptic_delays.html`
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
# Legacy BrainPy analysis
|
|
2
|
-
|
|
3
|
-
Use this reference when a legacy BrainPy 2.x model needs low-dimensional phase-plane or bifurcation analysis, fast-slow analysis, or numerical fixed-point discovery in a high-dimensional state space. Keep model construction and simulation in `brainpy legacy workflow.md`.
|
|
4
|
-
|
|
5
|
-
## Choose the analyzer
|
|
6
|
-
|
|
7
|
-
Low-dimensional analyzers work from named model variables and parameters. `SlowPointFinder` instead optimizes candidate states and is the normal choice once plotting the full state space is no longer meaningful.
|
|
8
|
-
|
|
9
|
-
| API | Use when |
|
|
10
|
-
|---|---|
|
|
11
|
-
| `bp.analysis.PhasePlane1D(model, target_vars, ...)` | Inspect the vector field and fixed points of one state variable. |
|
|
12
|
-
| `bp.analysis.PhasePlane2D(model, target_vars, ...)` | Inspect nullclines, vector fields, fixed points, and trajectories of two state variables. |
|
|
13
|
-
| `bp.analysis.Bifurcation1D(model, target_pars, target_vars, ...)` | Continue equilibria of a one-variable system while sweeping one or two parameters. |
|
|
14
|
-
| `bp.analysis.Bifurcation2D(model, target_pars, target_vars, ...)` | Continue equilibria of a two-variable system and classify local stability while parameters change. |
|
|
15
|
-
| `bp.analysis.FastSlow1D(model, fast_vars, slow_vars, ...)` | Treat one variable as fast and one or more variables as slowly varying bifurcation parameters. |
|
|
16
|
-
| `bp.analysis.FastSlow2D(model, fast_vars, slow_vars, ...)` | Analyze a two-variable fast subsystem across one or more slow variables. |
|
|
17
|
-
| `bp.analysis.SlowPointFinder(f_cell, ...)` | Find fixed or slow points in a high-dimensional callable or `DynamicalSystem` from supplied candidate states. |
|
|
18
|
-
|
|
19
|
-
Enable 64-bit computation before constructing an analyzer when numerical root finding or stability classification is sensitive to precision:
|
|
20
|
-
|
|
21
|
-
```python
|
|
22
|
-
import brainpy as bp
|
|
23
|
-
import brainpy.math as bm
|
|
24
|
-
|
|
25
|
-
bm.enable_x64()
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Define variables, parameters, and resolution
|
|
29
|
-
|
|
30
|
-
The analyzer separates coordinates being solved, parameters being swept, and values held fixed; preserve that distinction so the resulting diagram represents the intended system.
|
|
31
|
-
|
|
32
|
-
| Argument | Description |
|
|
33
|
-
|---|---|
|
|
34
|
-
| `target_vars={'name': [low, high]}` | Give each analyzed state variable and its search interval. Names must match model or integrator arguments. |
|
|
35
|
-
| `target_pars={'name': [low, high]}` | Give each parameter to sweep in a bifurcation analysis. |
|
|
36
|
-
| `pars_update={'name': value}` | Hold model parameters or external inputs at fixed values during analysis. |
|
|
37
|
-
| `fixed_vars={'name': value}` | Hold non-target state variables fixed when reducing a larger system. |
|
|
38
|
-
| `resolutions=step` | Use one grid step for all target dimensions. |
|
|
39
|
-
| `resolutions={'name': step}` | Control grid density per variable or parameter; refine only regions that need it. |
|
|
40
|
-
|
|
41
|
-
Do not place a swept value in `pars_update`; a value is either varied through `target_pars` or fixed through `pars_update` for one analysis.
|
|
42
|
-
|
|
43
|
-
## Analyze a two-variable phase plane
|
|
44
|
-
|
|
45
|
-
Use `PhasePlane2D` when the decision depends on nullcline intersections, flow direction, stability, or trajectories in a two-state system.
|
|
46
|
-
|
|
47
|
-
| API | Description |
|
|
48
|
-
|---|---|
|
|
49
|
-
| `plot_nullcline(...)` | Compute and optionally plot the two zero-derivative curves. |
|
|
50
|
-
| `plot_vector_field(plot_method='streamplot', ...)` | Plot the local flow; use `plot_method='quiver'` for arrows instead of streamlines. |
|
|
51
|
-
| `plot_fixed_point(...)` | Find and classify fixed points from the analysis grid. |
|
|
52
|
-
| `plot_trajectory(initials, duration, ...)` | Integrate trajectories from explicit initial states on the phase plane. |
|
|
53
|
-
| `show_figure()` | Display accumulated analysis plots when individual plot calls use `show=False`. |
|
|
54
|
-
|
|
55
|
-
```python
|
|
56
|
-
import brainpy as bp
|
|
57
|
-
import brainpy.math as bm
|
|
58
|
-
|
|
59
|
-
bm.enable_x64()
|
|
60
|
-
|
|
61
|
-
model = bp.neurons.FHN(1)
|
|
62
|
-
plane = bp.analysis.PhasePlane2D(
|
|
63
|
-
model=model,
|
|
64
|
-
target_vars={'V': [-3.0, 3.0], 'w': [-3.0, 3.0]},
|
|
65
|
-
pars_update={'I_ext': 0.8},
|
|
66
|
-
resolutions={'V': 0.01, 'w': 0.01},
|
|
67
|
-
)
|
|
68
|
-
plane.plot_nullcline(x_style={'fmt': '-'}, y_style={'fmt': '-'})
|
|
69
|
-
plane.plot_vector_field()
|
|
70
|
-
plane.plot_fixed_point()
|
|
71
|
-
plane.plot_trajectory(
|
|
72
|
-
initials={'V': [-2.0], 'w': [0.0]},
|
|
73
|
-
duration=100.0,
|
|
74
|
-
show=True,
|
|
75
|
-
)
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
**Invariant:** `target_vars` keys must identify the variables whose derivatives define the phase plane. A visually plausible plot with the wrong variable or parameter names analyzes a different system.
|
|
79
|
-
|
|
80
|
-
## Continue equilibria across parameters
|
|
81
|
-
|
|
82
|
-
Use a bifurcation analyzer when the question is how equilibria or their stability change as a parameter varies.
|
|
83
|
-
|
|
84
|
-
```python
|
|
85
|
-
import brainpy as bp
|
|
86
|
-
import brainpy.math as bm
|
|
87
|
-
|
|
88
|
-
bm.enable_x64()
|
|
89
|
-
|
|
90
|
-
model = bp.dyn.ExpIF(1, delta_T=1.0)
|
|
91
|
-
bifurcation = bp.analysis.Bifurcation1D(
|
|
92
|
-
model=model,
|
|
93
|
-
target_vars={'V': [-70.0, -55.0]},
|
|
94
|
-
target_pars={'I': [0.0, 6.0]},
|
|
95
|
-
resolutions={'I': 0.01},
|
|
96
|
-
)
|
|
97
|
-
bifurcation.plot_bifurcation(show=True)
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Use a dictionary of per-parameter resolutions when a narrow transition region needs a finer grid. Use `num_rank` on two-dimensional bifurcation plots to increase the number of initial candidates only after verifying the variable and parameter ranges.
|
|
101
|
-
|
|
102
|
-
## Find high-dimensional fixed or slow points
|
|
103
|
-
|
|
104
|
-
`SlowPointFinder` minimizes state change rather than drawing a state-space grid; candidate coverage therefore determines which fixed points can be found.
|
|
105
|
-
|
|
106
|
-
| API | Description |
|
|
107
|
-
|---|---|
|
|
108
|
-
| `SlowPointFinder(f_cell, f_type=..., target_vars=..., inputs=...)` | Bind a callable or model, optionally restrict the optimized variables, and hold explicit model inputs fixed. |
|
|
109
|
-
| `find_fps_with_gd_method(candidates, tolerance=..., num_batch=..., num_opt=...)` | Optimize batches of candidate states with gradient descent. |
|
|
110
|
-
| `find_fps_with_opt_solver(candidates, opt_solver='BFGS')` | Use a named optimization solver instead of the gradient-descent path. |
|
|
111
|
-
| `filter_loss(tolerance)` | Remove candidates whose fixed-point loss remains above the threshold. |
|
|
112
|
-
| `keep_unique(tolerance)` | Remove fixed points closer than the uniqueness tolerance. |
|
|
113
|
-
| `compute_jacobians(points, plot=False, ...)` | Linearize the dynamics at retained points and return their Jacobians. |
|
|
114
|
-
|
|
115
|
-
```python
|
|
116
|
-
# Given a constructed legacy BrainPy model with Variables V and w:
|
|
117
|
-
finder = bp.analysis.SlowPointFinder(
|
|
118
|
-
f_cell=model,
|
|
119
|
-
target_vars={'V': model.V, 'w': model.w},
|
|
120
|
-
inputs=[model.Iext, fixed_input],
|
|
121
|
-
)
|
|
122
|
-
finder.find_fps_with_gd_method(
|
|
123
|
-
candidates={
|
|
124
|
-
'V': bm.random.normal(0.0, 2.0, (1000, model.num)),
|
|
125
|
-
'w': bm.random.normal(0.0, 1.0, (1000, model.num)),
|
|
126
|
-
},
|
|
127
|
-
tolerance=1e-5,
|
|
128
|
-
num_batch=200,
|
|
129
|
-
)
|
|
130
|
-
finder.filter_loss(1e-5)
|
|
131
|
-
finder.keep_unique(1e-3)
|
|
132
|
-
jacobians = finder.compute_jacobians(finder.fixed_points)
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
Treat the last example as a composition pattern: `model`, `model.Iext`, and `fixed_input` must come from the actual model. Sample candidates around states reached in simulation when random candidates do not cover the relevant attractor basin.
|
|
136
|
-
|
|
137
|
-
## Common failures
|
|
138
|
-
|
|
139
|
-
- Enable x64 before creating analyzers, not after an analysis has already been traced.
|
|
140
|
-
- Do not infer exhaustive fixed-point coverage from one candidate distribution.
|
|
141
|
-
- Filter by loss before interpreting or deduplicating optimized points.
|
|
142
|
-
- Use `f_type='continuous'` when a raw callable returns continuous-time derivatives; verify the callable convention before optimization.
|
|
143
|
-
- Compare analysis predictions with a `DSRunner` trajectory before treating a fixed point or bifurcation branch as scientifically meaningful.
|
|
144
|
-
|
|
145
|
-
## Sources mirrored
|
|
146
|
-
|
|
147
|
-
- https://brainpy.readthedocs.io/apis/analysis.html
|
|
148
|
-
- https://brainpy.readthedocs.io/tutorial_analysis/lowdim_analysis.html
|
|
149
|
-
- https://brainpy.readthedocs.io/tutorial_analysis/highdim_analysis.html
|
|
150
|
-
- https://brainpy.readthedocs.io/tutorial_analysis/decision_making_model.html
|