artlib.optimized.backends.torch.BinaryFuzzyARTMAP

Binary Fuzzy ARTMAP (Torch-accelerated backend)

Classes

_TorchBinaryFuzzyARTMAPConfig

_TorchBinaryFuzzyARTMAP

Torch-accelerated Binary Fuzzy ARTMAP with export hooks for artlib sync.

BinaryFuzzyARTMAP

BinaryFuzzyARTMAP for Classification. optimized with torch.

Functions

_to_device(→ torch.Tensor)

_complement_code_any(→ torch.Tensor)

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
input_dim: int
alpha: float = 1e-10
rho: float = 0.75
epsilon: float = 1e-07
match_tracking: bool = True
device: str = 'cuda'
dtype: torch.dtype = Ellipsis
clamp_inputs: bool = True
fallback_to_choice_on_fail: bool = True
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
W: torch.Tensor | None = None
map_y: torch.Tensor | None = None
_lower_bounds: torch.Tensor | None = None
_upper_bounds: torch.Tensor | None = None
_prep_tol: float = 1e-06
property n_cat: int
_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)
_free_mem_bytes() int
_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)

_commit_new_category(I: torch.Tensor, y: int)
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._TorchSimpleARTMAP

BinaryFuzzyARTMAP 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 SimpleARTMAP instantiated with BinaryFuzzyART.

_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.