artlib.optimized.backends.torch.BinaryFuzzyARTMAP
Binary Fuzzy ARTMAP (Torch-accelerated backend)
Classes
Torch-accelerated Binary Fuzzy ARTMAP with export hooks for artlib sync. |
|
BinaryFuzzyARTMAP for Classification. optimized with torch. |
Functions
|
|
|
Complement-code that works for float or bool tensors. |
Module Contents
- artlib.optimized.backends.torch.BinaryFuzzyARTMAP._to_device(x: torch.Tensor | numpy.ndarray, device, dtype=torch.bool) torch.Tensor
- artlib.optimized.backends.torch.BinaryFuzzyARTMAP._complement_code_any(x: torch.Tensor) torch.Tensor
Complement-code that works for float or bool tensors.
- class artlib.optimized.backends.torch.BinaryFuzzyARTMAP._TorchBinaryFuzzyARTMAPConfig
-
- dtype: torch.dtype = Ellipsis
- class artlib.optimized.backends.torch.BinaryFuzzyARTMAP._TorchBinaryFuzzyARTMAP(cfg: _TorchBinaryFuzzyARTMAPConfig)
Torch-accelerated Binary Fuzzy ARTMAP with export hooks for artlib sync.
- cfg
- device
- dtype
- input_dim
- code_dim
- _ensure_capacity()
- set_data_bounds(lower: torch.Tensor | numpy.ndarray, upper: torch.Tensor | numpy.ndarray)
- prepare_data(X: torch.Tensor | numpy.ndarray) torch.Tensor
Optional helper: normalize -> complement-code -> binarize -> bool. If your inputs are already binary and complement-coded, skip this and pass them straight to partial_fit_and_export/predict_*.
- _validate_prepared(X: torch.Tensor)
- _choice_and_match(I: torch.Tensor) Tuple[torch.Tensor, torch.Tensor, torch.Tensor]
For a single prepared binary input I (bool), return:
T: [K] choice values m: [K] match values w_sum: [K] |w| (as float64)
- partial_fit_and_export(X_prepared: torch.Tensor | numpy.ndarray, y: torch.Tensor | numpy.ndarray, epsilon: float = 1e-10, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+') Tuple[numpy.ndarray, list[numpy.ndarray], numpy.ndarray]
Incremental training on already-prepared, binary, complement-coded inputs.
- Returns:
(N,) chosen A-side category indices (int) weights_arrays: list of K arrays, each weight as uint8 cluster_labels_out: (K,) map from A categories to B labels (int)
- Return type:
labels_a_out
- predict_ab_prepared(X_prepared: torch.Tensor | numpy.ndarray) Tuple[numpy.ndarray, numpy.ndarray]
- class artlib.optimized.backends.torch.BinaryFuzzyARTMAP.BinaryFuzzyARTMAP(rho: float, alpha: float, input_dim: int | None = None, device: str = 'cuda')
Bases:
artlib.optimized.backends.torch._TorchSimpleARTMAP._TorchSimpleARTMAPBinaryFuzzyARTMAP for Classification. optimized with torch.
This module implements BinaryFuzzyARTMAP
BinaryFuzzyARTMAP is a non-modular classification model which has been highly optimized for run-time performance. Fit and predict functions are implemented in torch for efficient execution. This class acts as a wrapper for the underlying torch functions and to provide compatibility with the artlib style and usage. Functionally, BinaryFuzzyARTMAP behaves as a special case of
SimpleARTMAPinstantiated withBinaryFuzzyART.- _device = 'cuda'
- _backend: _TorchBinaryFuzzyARTMAP | None = None
- _declared_input_dim = None
- _ensure_backend(X: numpy.ndarray)
Initialize backend using prepared X to infer raw dimension when needed.