ncalab.models.applications.classification.classificationNCA =========================================================== .. py:module:: ncalab.models.applications.classification.classificationNCA Classes ------- .. autoapisummary:: ncalab.models.applications.classification.classificationNCA.ClassificationNCAModel Module Contents --------------- .. py:class:: ClassificationNCAModel(device: torch.device, num_image_channels: int, num_hidden_channels: int, num_classes: int, fire_rate: float = 0.8, hidden_size: int = 128, use_alive_mask: bool = False, pixel_wise_loss: bool = False, num_learned_filters: int = 2, filter_padding: str = 'reflect', use_laplace: bool = False, kernel_size: int = 3, pad_noise: bool = False, use_temporal_encoding: bool = False, use_classifier: bool = True, class_names: Optional[List[str]] = None, avg_pool_size: int = 5, **kwargs) Bases: :py:obj:`ncalab.models.basicNCA.BasicNCAModel` Abstract base class for NCA models. BasicNCAModel is a composition of an NCA backbone model (called "rule"), and an (optional) head module for downstream tasks. :param device: Pytorch device descriptor. :param num_image_channels: _description_ :param num_hidden_channels: _description_ :param num_classes: _description_ :param fire_rate: Fire rate for stochastic weight update. Defaults to 0.8. :param hidden_size: Number of neurons in hidden layer. Defaults to 128. :param use_alive_mask: Whether to use alive masking (channel 3) during training. Defaults to False. :param pixel_wise_loss: Whether a prediction per pixel is desired, like in self-classifying MNIST. Defaults to False. :param num_learned_filters: Number of learned filters. If zero, use two sobel filters instead. Defaults to 2. :param filter_padding: Padding type to use. Might affect reliance on spatial cues. Defaults to "circular". :param pad_noise: Whether to pad input image tensor with noise in hidden / output channels .. py:attribute:: _num_classes .. py:attribute:: pixel_wise_loss :value: False .. py:attribute:: use_classifier :value: True .. py:attribute:: avg_pool_size :value: 5 .. py:property:: num_classes :type: int .. py:method:: classify(image: torch.Tensor, steps: int = 100, reduce: bool = False) -> torch.Tensor Predict classification for an input image. :param image: Input image. :param steps: Inference steps. Defaults to 100. :param reduce: Return a single softmax probability. Defaults to False. :returns: Single class index or vector of logits. .. py:method:: loss(pred: ncalab.prediction.Prediction, label: torch.Tensor) -> Dict[str, torch.Tensor] Return the classification loss. :param pred: Prediction. :param label: Ground truth. :returns: Dictionary of identifiers mapped to computed losses. .. py:method:: metrics(pred: ncalab.prediction.Prediction, label: torch.Tensor) -> Dict[str, float] Return dict of standard evaluation metrics. :param pred: Prediction :type pred: Prediction :param label: Ground truth label. :type label: Tensor