ncalab.models.basicNCA.mlpNCArule ================================= .. py:module:: ncalab.models.basicNCA.mlpNCArule Classes ------- .. autoapisummary:: ncalab.models.basicNCA.mlpNCArule.MLPNCARule Module Contents --------------- .. py:class:: MLPNCARule(device: torch.device, input_size: int, hidden_size: int, output_size: int, nonlinearity: type[torch.nn.Module] = nn.ReLU) Bases: :py:obj:`ncalab.models.basicNCA.abstractNCArule.AbstractNCARule` NCA rule module based on a two-layer Multi-Layer-Perceptron (MLP). :param nn: _description_ :type nn: _type_ :param device: Compute device :type device: torch.device :param input_size: Input neurons :type input_size: int :param hidden_size: Hidden neurons :type hidden_size: int :param output_size: Output neurons :type output_size: int :param nonlinearity: Activation function, defaults to nn.ReLU :type nonlinearity: type[nn.Module], optional .. py:attribute:: nonlinearity .. 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