artlib.optimized.backends.torch.HypersphereARTMAP ================================================= .. py:module:: artlib.optimized.backends.torch.HypersphereARTMAP .. autoapi-nested-parse:: Hypersphere ARTMAP (Torch-accelerated backend) Classes ------- .. autoapisummary:: artlib.optimized.backends.torch.HypersphereARTMAP._TorchHypersphereARTMAPConfig artlib.optimized.backends.torch.HypersphereARTMAP._TorchHypersphereARTMAP artlib.optimized.backends.torch.HypersphereARTMAP.HypersphereARTMAP Functions --------- .. autoapisummary:: artlib.optimized.backends.torch.HypersphereARTMAP._to_device Module Contents --------------- .. py:function:: _to_device(x: Union[torch.Tensor, numpy.ndarray], device, dtype=torch.float32) -> torch.Tensor .. py:class:: _TorchHypersphereARTMAPConfig .. py:attribute:: input_dim :type: int .. py:attribute:: alpha :type: float :value: 0.001 .. py:attribute:: rho :type: float :value: 0.75 .. py:attribute:: beta :type: float :value: 1.0 .. py:attribute:: r_hat :type: float :value: 1.0 .. py:attribute:: device :type: str :value: 'cuda' .. py:attribute:: dtype :type: torch.dtype :value: Ellipsis .. py:attribute:: clamp_inputs :type: bool :value: False .. py:class:: _TorchHypersphereARTMAP(cfg: _TorchHypersphereARTMAPConfig) Bases: :py:obj:`artlib.optimized.backends.torch._TorchSimpleARTMAP._TorchSimpleARTMAP` GPU-accelerated Hypersphere ARTMAP with export hooks for artlib synchronization. .. py:attribute:: cfg .. py:attribute:: device .. py:attribute:: dtype .. py:attribute:: input_dim .. py:attribute:: weight_dim .. py:attribute:: W :type: Optional[torch.Tensor] :value: None .. py:attribute:: map_y :type: Optional[torch.Tensor] :value: None .. py:attribute:: _prep_tol :type: float :value: 1e-06 .. py:property:: n_cat :type: int .. py:method:: _ensure_capacity() .. py:method:: _prep_input(X: torch.Tensor) -> torch.Tensor .. py:method:: _validate_prepared(X: torch.Tensor) .. py:method:: _free_mem_bytes() -> int .. py:method:: _choice_and_match(I: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor] Returns (T, m, I_radius, max_radius) for a single prepared input I. .. py:method:: _commit_new_category(I: torch.Tensor, y: int) Start a new hypersphere at sample I with radius 0. .. py:method:: partial_fit_and_export(X_prepared: Union[torch.Tensor, numpy.ndarray], y: Union[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] .. py:method:: predict_ab_prepared(X_prepared: Union[torch.Tensor, numpy.ndarray]) -> Tuple[numpy.ndarray, numpy.ndarray] .. py:class:: HypersphereARTMAP(rho: float, alpha: float, beta: float, r_hat: float, input_dim: Optional[int] = None, device: str = 'cuda', dtype: torch.dtype = torch.float64, clamp_inputs: bool = False) Bases: :py:obj:`artlib.supervised.SimpleARTMAP.SimpleARTMAP` HypersphereARTMAP for Classification. optimized with torch. This module implements HypersphereARTMAP HypersphereARTMAP 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, HypersphereARTMAP behaves as a special case of :class:`~artlib.supervised.SimpleARTMAP.SimpleARTMAP` instantiated with :class:`~artlib.elementary.HypersphereART.HypersphereART`. .. py:attribute:: _device :value: 'cuda' .. py:attribute:: _dtype :value: Ellipsis .. py:attribute:: _clamp :value: False .. py:attribute:: _backend :type: Optional[_TorchHypersphereARTMAP] :value: None .. py:attribute:: _declared_input_dim :value: None .. py:method:: _ensure_backend(X: numpy.ndarray)