Repeat#
- class deeptrack.features.Repeat(feature: Feature, N: int, **kwargs: dict[str, Any])#
Bases:
FeatureApplies a feature multiple times in sequence.
The Repeat feature iteratively applies another feature, passing the output of each iteration as the input to the next. This enables chained transformations, where each iteration builds upon the previous one. The number of repetitions is defined by N.
Each iteration operates with its own set of properties, and the index of the current iteration is accessible via _ID or replicate_index. _ID is extended to include the current iteration index, ensuring deterministic behavior when needed.
Parameters#
- feature: Feature
The feature to be repeated.
- N: int
The number of times to apply the feature in sequence.
**kwargs: dict of str to Any
Attributes#
- __distributed__: bool
Always False for Repeat, since it processes sequentially rather than distributing computation across inputs.
Methods#
- get(image: Any, N: int, _ID: tuple[int, …], **kwargs: dict[str, Any]) -> Any
Applies the feature N times in sequence, passing the output of each iteration as the input to the next.
Examples#
>>> import deeptrack as dt
Define an Add feature that adds 10 to its input: >>> add_ten = dt.Add(value=10)
Apply this feature 3 times using Repeat: >>> pipeline = dt.Repeat(add_ten, N=3)
Process an input list: >>> print(pipeline.resolve([1, 2, 3])) [31, 32, 33]
Step-by-step breakdown: - Iteration 1: [1, 2, 3] + 10 → [11, 12, 13] - Iteration 2: [11, 12, 13] + 10 → [21, 22, 23] - Iteration 3: [21, 22, 23] + 10 → [31, 32, 33]
Alternative shorthand using ^ operator: >>> pipeline = dt.Add(value=10) ^ 3 >>> print(pipeline.resolve([1, 2, 3])) [31, 32, 33]
Methods Summary
get(image, N[, _ID])Sequentially apply the feature N times.
Methods Documentation
- get(image: Any, N: int, _ID: tuple[int, ...] = (), **kwargs: dict[str, Any]) Any#
Sequentially apply the feature N times.
This method applies the feature N times, passing the output of each iteration as the input to the next. The _ID tuple is updated at each iteration, ensuring dynamic property updates and reproducibility.
Parameters#
- image: Any
The input data to be transformed by the repeated feature.
- N: int
The number of times to sequentially apply the feature, where each iteration builds on the previous output.
- _ID: tuple[int, …], optional
A unique identifier for tracking the iteration index, ensuring reproducibility, caching, and dynamic property updates.
- **kwargs: dict of str to Any
Additional keyword arguments passed to the feature.
Returns#
- Any
The output of the final iteration after N sequential applications of the feature.