iactrace.utils¶
Utility functions for sampling and optimization.
Sampling Functions¶
Functions for sampling points on geometric shapes:
Filtering (for optimization)¶
Utilities for filtering pytree parameters during gradient-based optimization.
- iactrace.utils.filtering.make_filter(model, trainable=None, frozen=None)[source]¶
Create a filter spec for eqx.partition.
- Args:
model: The pytree to filter trainable: Paths to train (everything else frozen), can be:
str: single pattern
Sequence[str]: list of patterns
Callable[[path_tuple, leaf], bool]: custom filter
frozen: Paths to freeze (everything else trainable), same types
- Returns:
Filter spec (pytree of bools matching model structure)
- Patterns:
‘mirror_groups.rotations’ - exact match ‘mirror_groups.*’ - all direct children ‘mirror_groups.*.rotations’ - rotations in any child ‘**.rotations’ - any path ending in rotations
- Examples:
# Only train mirror rotations make_filter(tel, trainable=’mirror_groups.*.rotations’)
# Train all mirror group params make_filter(tel, trainable=’mirror_groups.**’)
# Freeze only sensor positions make_filter(tel, frozen=’sensors.*.position’)
# Custom filter make_filter(tel, trainable=lambda path, leaf: ‘rotation’ in str(path))