|
| 1 | +``braintools.param`` module |
| 2 | +=========================== |
| 3 | + |
| 4 | +.. currentmodule:: braintools.param |
| 5 | +.. automodule:: braintools.param |
| 6 | + |
| 7 | +Parameter transformation module for constrained optimization and probabilistic modeling. |
| 8 | +Provides bijective transforms that map between unconstrained and constrained parameter spaces. |
| 9 | + |
| 10 | +Overview |
| 11 | +-------- |
| 12 | + |
| 13 | +The ``braintools.param`` module provides: |
| 14 | + |
| 15 | +- **Bijective transformations** for mapping parameters between constrained and unconstrained domains |
| 16 | +- **Parameter wrapper** (``Param``) that automatically applies transforms during optimization |
| 17 | +- **Jacobian computation** via ``log_abs_det_jacobian`` for probabilistic modeling |
| 18 | +- **Composition utilities** for building complex transforms from simple ones |
| 19 | + |
| 20 | +Base Classes |
| 21 | +------------ |
| 22 | + |
| 23 | +These classes provide the foundational architecture for all transforms in the module. |
| 24 | +The ``Transform`` class defines the common interface with ``forward``, ``inverse``, |
| 25 | +and ``log_abs_det_jacobian`` methods. |
| 26 | + |
| 27 | +.. autosummary:: |
| 28 | + :toctree: generated/ |
| 29 | + :nosignatures: |
| 30 | + :template: classtemplate.rst |
| 31 | + |
| 32 | + Transform |
| 33 | + Identity |
| 34 | + |
| 35 | +Parameter Wrapper |
| 36 | +----------------- |
| 37 | + |
| 38 | +The ``Param`` class wraps parameter values and automatically applies bijective |
| 39 | +transformations. It stores values in unconstrained space internally while exposing |
| 40 | +constrained values via the ``.data`` property. |
| 41 | + |
| 42 | +.. autosummary:: |
| 43 | + :toctree: generated/ |
| 44 | + :nosignatures: |
| 45 | + :template: classtemplate.rst |
| 46 | + |
| 47 | + Param |
| 48 | + |
| 49 | +Bounded Transforms |
| 50 | +------------------ |
| 51 | + |
| 52 | +These transforms map unbounded values to bounded intervals. They are useful for |
| 53 | +parameters that must lie within specific ranges, such as probabilities, correlation |
| 54 | +coefficients, or physical quantities with known bounds. |
| 55 | + |
| 56 | +.. autosummary:: |
| 57 | + :toctree: generated/ |
| 58 | + :nosignatures: |
| 59 | + :template: classtemplate.rst |
| 60 | + |
| 61 | + Sigmoid |
| 62 | + ScaledSigmoid |
| 63 | + Tanh |
| 64 | + Softsign |
| 65 | + Clip |
| 66 | + |
| 67 | +- **Sigmoid**: Maps ℝ → [lower, upper] using the logistic sigmoid function |
| 68 | +- **ScaledSigmoid**: Sigmoid with adjustable sharpness/temperature parameter |
| 69 | +- **Tanh**: Maps ℝ → (lower, upper) using hyperbolic tangent |
| 70 | +- **Softsign**: Maps ℝ → (lower, upper) using softsign function |
| 71 | +- **Clip**: Hard clipping to bounds (non-bijective) |
| 72 | + |
| 73 | +Positive/Negative Transforms |
| 74 | +---------------------------- |
| 75 | + |
| 76 | +These transforms constrain parameters to be strictly positive or negative. |
| 77 | +They are commonly used for variance parameters, rate constants, and other |
| 78 | +quantities that must maintain a specific sign. |
| 79 | + |
| 80 | +.. autosummary:: |
| 81 | + :toctree: generated/ |
| 82 | + :nosignatures: |
| 83 | + :template: classtemplate.rst |
| 84 | + |
| 85 | + Softplus |
| 86 | + NegSoftplus |
| 87 | + Log |
| 88 | + Exp |
| 89 | + Positive |
| 90 | + Negative |
| 91 | + |
| 92 | +- **Softplus**: Maps ℝ → [lower, ∞) using log(1 + exp(x)) |
| 93 | +- **NegSoftplus**: Maps ℝ → (-∞, upper] using negative softplus |
| 94 | +- **Log/Exp**: Maps ℝ → (lower, ∞) using exponential transformation |
| 95 | +- **Positive**: Convenience class for (0, ∞) constraint |
| 96 | +- **Negative**: Convenience class for (-∞, 0) constraint |
| 97 | + |
| 98 | +Advanced Transforms |
| 99 | +------------------- |
| 100 | + |
| 101 | +These transforms implement sophisticated constraints for specialized applications |
| 102 | +in probabilistic modeling, ordinal regression, and directional statistics. |
| 103 | + |
| 104 | +.. autosummary:: |
| 105 | + :toctree: generated/ |
| 106 | + :nosignatures: |
| 107 | + :template: classtemplate.rst |
| 108 | + |
| 109 | + Power |
| 110 | + Ordered |
| 111 | + Simplex |
| 112 | + UnitVector |
| 113 | + |
| 114 | +- **Power**: Box-Cox family power transformation for variance stabilization |
| 115 | +- **Ordered**: Ensures monotonically increasing output vectors (useful for cutpoints) |
| 116 | +- **Simplex**: Stick-breaking transformation for probability vectors summing to 1 |
| 117 | +- **UnitVector**: Projects vectors onto the unit sphere (L2 norm = 1) |
| 118 | + |
| 119 | +Composition Transforms |
| 120 | +---------------------- |
| 121 | + |
| 122 | +These transforms allow building complex transformations from simpler ones. |
| 123 | +They support chaining, masking, and custom user-defined transformations. |
| 124 | + |
| 125 | +.. autosummary:: |
| 126 | + :toctree: generated/ |
| 127 | + :nosignatures: |
| 128 | + :template: classtemplate.rst |
| 129 | + |
| 130 | + Affine |
| 131 | + Chain |
| 132 | + Masked |
| 133 | + Custom |
| 134 | + |
| 135 | +- **Affine**: Linear transformation y = ax + b |
| 136 | +- **Chain**: Composes multiple transforms sequentially |
| 137 | +- **Masked**: Applies transform selectively based on boolean mask |
| 138 | +- **Custom**: User-defined transformation with custom forward/inverse functions |
0 commit comments