nnrl/optim/kfac.py
def save_input(self, mod, inputs):
        """Saves input of layer to compute covariance.

        Note: inputs must be divided by the batch size to weight them appropriately
        when computing the average whitening matrix.
        """
        inputs = inputs[0].detach()
        if isinstance(mod, nn.Linear):
            inputs = inputs.reshape(-1, inputs.shape[-1])
        elif isinstance(mod, nn.Conv2d):
            inputs = inputs.reshape(-1, *inputs.shape[-3:])
        self.state[mod.weight]["x"] = inputs / inputs.shape[0]
Saves input of layer to compute covariance.

        Note: inputs must be divided by the batch size to weight them appropriately
        when computing the average whitening matrix.
        
Saves input of layer to compute covariance.
Note: inputs must be divided by the batch size to weight them appropriately
when computing the average whitening matrix.
Saves input of layer to compute covariance . Note : inputs must be divided by the batch size to weight them appropriately when computing the average whitening matrix .
def save_input(self, mod, inputs):
        inputs = inputs[0].detach()
        if isinstance(mod, nn.Linear):
            inputs = inputs.reshape(-1, inputs.shape[-1])
        elif isinstance(mod, nn.Conv2d):
            inputs = inputs.reshape(-1, *inputs.shape[-3:])
        self.state[mod.weight]["x"] = inputs / inputs.shape[0]
def save_input ( self , mod , inputs ) : inputs = inputs [ 0 ] . detach ( ) if isinstance ( mod , nn . Linear ) : inputs = inputs . reshape ( - 1 , inputs . shape [ - 1 ] ) elif isinstance ( mod , nn . Conv2d ) : inputs = inputs . reshape ( - 1 , * inputs . shape [ - 3 : ] ) self . state [ mod . weight ] [ "x" ] = inputs / inputs . shape [ 0 ]
Saves input of layer to compute covariance.
Saves input of layer to compute covariance .
"""Saves input of layer to compute covariance.

        Note: inputs must be divided by the batch size to weight them appropriately
        when computing the average whitening matrix.
        """
self
mod
inputs