carpet/lista_analysis.py
def forward(self, x, lbda, output_layer=None):
        """ Forward pass of the network. """
        output_layer = self.check_output_layer(output_layer)

        # initialized variables
        v, u, _ = init_vuz(self.A, self.D, x, inv_A=self.inv_A_,
                           device=self.device)
        v_old, u_old, _ = init_vuz(self.A, self.D, x, device=self.device)

        for layer_id in range(output_layer):
            layer_params = self.parameter_groups[f'layer-{layer_id}']
            # retrieve parameters
            sigma = layer_params['sigma']
            sigma = torch.clamp(sigma, 0.5, 2.0)  # TODO constraint learning
            tau = 1.0 / (self.l_A / 2.0 + sigma * self.l_D**2)
            rho = self.rho

            # primal descent
            u_new = u_old + (
                - tau * (u_old.matmul(self.A_) - x).matmul(self.A_.t())
                - tau * v_old.matmul(self.D_.t()))
            # dual ascent
            v_ = v_old + sigma * (2 * u_new - u_old).matmul(self.D_)
            v_new = v_ - sigma * pseudo_soft_th_tensor(
                v_ / sigma, lbda, 1.0 / sigma)
            # update
            u = rho * u_new + (1.0 - rho) * u_old
            v = rho * v_new + (1.0 - rho) * v_old
            # storing
            u_old = u
            v_old = v

        return u
 Forward pass of the network. 
Forward pass of the network.
Forward pass of the network .
def forward(self, x, lbda, output_layer=None):
        output_layer = self.check_output_layer(output_layer)
        v, u, _ = init_vuz(self.A, self.D, x, inv_A=self.inv_A_,
                           device=self.device)
        v_old, u_old, _ = init_vuz(self.A, self.D, x, device=self.device)
        for layer_id in range(output_layer):
            layer_params = self.parameter_groups[f'layer-{layer_id}']
            sigma = layer_params['sigma']
            sigma = torch.clamp(sigma, 0.5, 2.0)  
            tau = 1.0 / (self.l_A / 2.0 + sigma * self.l_D**2)
            rho = self.rho
            u_new = u_old + (
                - tau * (u_old.matmul(self.A_) - x).matmul(self.A_.t())
                - tau * v_old.matmul(self.D_.t()))
            v_ = v_old + sigma * (2 * u_new - u_old).matmul(self.D_)
            v_new = v_ - sigma * pseudo_soft_th_tensor(
                v_ / sigma, lbda, 1.0 / sigma)
            u = rho * u_new + (1.0 - rho) * u_old
            v = rho * v_new + (1.0 - rho) * v_old
            u_old = u
            v_old = v
        return u
def forward ( self , x , lbda , output_layer = None ) : output_layer = self . check_output_layer ( output_layer ) v , u , _ = init_vuz ( self . A , self . D , x , inv_A = self . inv_A_ , device = self . device ) v_old , u_old , _ = init_vuz ( self . A , self . D , x , device = self . device ) for layer_id in range ( output_layer ) : layer_params = self . parameter_groups [ f'layer-{layer_id}' ] sigma = layer_params [ 'sigma' ] sigma = torch . clamp ( sigma , 0.5 , 2.0 ) tau = 1.0 / ( self . l_A / 2.0 + sigma * self . l_D ** 2 ) rho = self . rho u_new = u_old + ( - tau * ( u_old . matmul ( self . A_ ) - x ) . matmul ( self . A_ . t ( ) ) - tau * v_old . matmul ( self . D_ . t ( ) ) ) v_ = v_old + sigma * ( 2 * u_new - u_old ) . matmul ( self . D_ ) v_new = v_ - sigma * pseudo_soft_th_tensor ( v_ / sigma , lbda , 1.0 / sigma ) u = rho * u_new + ( 1.0 - rho ) * u_old v = rho * v_new + ( 1.0 - rho ) * v_old u_old = u v_old = v return u
Forward pass of the network.
Forward pass of the network .
""" Forward pass of the network. """ # initialized variables # retrieve parameters # TODO constraint learning # primal descent # dual ascent # update # storing
self
x
lbda
output_layer