ncalab.models.basicNCA.basicNCArule =================================== .. py:module:: ncalab.models.basicNCA.basicNCArule Classes ------- .. autoapisummary:: ncalab.models.basicNCA.basicNCArule.BasicNCARule Module Contents --------------- .. py:class:: BasicNCARule(device: torch.device, input_size: int, hidden_size: int, output_size: int, nonlinearity: type[torch.nn.Module] = nn.ReLU) Bases: :py:obj:`torch.nn.Module` NCA rule module based on a two-layer Multi-Layer-Perceptron (MLP). :param nn: _description_ :type nn: _type_ _summary_ :param device: _description_ :type device: torch.device :param input_size: _description_ :type input_size: int :param hidden_size: _description_ :type hidden_size: int :param output_size: _description_ :type output_size: int :param nonlinearity: _description_, defaults to nn.ReLU :type nonlinearity: type[nn.Module], optional .. py:attribute:: nonlinearity .. py:attribute:: input_size .. py:attribute:: hidden_size .. py:attribute:: output_size .. py:attribute:: device .. py:method:: _build_network() .. py:method:: _initialize_network() Initialize network weights of the MLP. We assume that the default initialization of the first layer is good enough. Since the final layer is purely linear and unbiased, we initalize with 0. .. py:method:: forward(x: torch.Tensor) -> torch.Tensor :param x: BCWH perception vector :type x: torch.Tensor :return: BCWH residual update :rtype: torch.Tensor .. py:method:: freeze(freeze_last: bool = False) Freeze the first layer of the NCA rule network and, optionally, the final layer. :param freeze_last: _description_, defaults to False :type freeze_last: bool, optional