(self, x)
return (x * w.view(*view)).sum(dim=self.collapse_dim)
Perform forward pass.

        Parameters
        ----------
        x : torch.Tensor
            N-dimensional tensor of shape (d_0, d_1, ..., d_{N-1}).

        Returns
        -------
        torch.Tensor
            {N-1}-dimensional tensor of shape (d_0, ..., d_{collapse_dim - 1}, d_{collapse_dim + 1}, ..., d_{N-1}).
            Exponential Average over the removed dimension.
Perform forward pass.
Perform forward pass .
def forward(self, x):
        """Perform forward pass.

        Parameters
        ----------
        x : torch.Tensor
            N-dimensional tensor of shape (d_0, d_1, ..., d_{N-1}).

        Returns
        -------
        torch.Tensor
            {N-1}-dimensional tensor of shape (d_0, ..., d_{collapse_dim - 1}, d_{collapse_dim + 1}, ..., d_{N-1}).
            Exponential Average over the removed dimension.
        """
        n_steps = x.shape[self.collapse_dim]
        n_dim = x.ndim
        view = [-1 if i == self.collapse_dim else 1 for i in range(n_dim)]

        w_unscaled = [1]
        for _ in range(1, n_steps):
            w_unscaled.append(self.forgetting_factor * w_unscaled[-1] + 1)

        w_unscaled = torch.Tensor(w_unscaled).to(dtype=x.dtype, device=x.device)
        w = w_unscaled / w_unscaled.sum()

        return (x * w.view(*view)).sum(dim=self.collapse_dim)
def forward ( self , x ) : n_steps = x . shape [ self . collapse_dim ] n_dim = x . ndim view = [ - 1 if i == self . collapse_dim else 1 for i in range ( n_dim ) ] w_unscaled = [ 1 ] for _ in range ( 1 , n_steps ) : w_unscaled . append ( self . forgetting_factor * w_unscaled [ - 1 ] + 1 ) w_unscaled = torch . Tensor ( w_unscaled ) . to ( dtype = x . dtype , device = x . device ) w = w_unscaled / w_unscaled . sum ( ) return ( x * w . view ( * view ) ) . sum ( dim = self . collapse_dim )