carpet/lista_base.py
def _fit_all_network_batch_gradient_descent(self, x, lbda):
        """ Fit the parameters of the network. """
        if self.net_solver_type == 'one_shot':
            params = self.get_params_to_learn(up_to_layer=self.n_layers)
            self._fit_sub_net_batch_gd(
                x, lbda, params, self.n_layers, self.max_iter,
                output_layer=self.n_layers
            )

        elif self.net_solver_type == 'recursive':
            layers = range(self.train_from, self.n_layers + 1)
            max_iters = np.diff(np.linspace(0, self.max_iter, len(layers) + 1,
                                            dtype=int))
            for layer_id, max_iter in zip(layers, max_iters):
                if max_iter == 0:
                    continue
                params = self.get_params_to_learn(up_to_layer=layer_id)
                self._fit_sub_net_batch_gd(x, lbda, params, layer_id, max_iter,
                                           output_layer=layer_id)

        elif self.net_solver_type == 'greedy':
            layers = range(1, self.n_layers + 1)
            max_iters = np.diff(np.linspace(0, self.max_iter, self.n_layers+1,
                                            dtype=int))
            for layer_id, max_iter in zip(layers, max_iters):
                if max_iter == 0:
                    continue
                params = self.get_params_to_learn(up_to_layer=layer_id)
                self._fit_sub_net_batch_gd(x, lbda, params, layer_id, max_iter,
                                           output_layer=self.n_layers)

        else:
            raise ValueError(f"net_solver_type should belong to "
                             f"['recursive', 'one_shot', 'greedy']"
                             f", got {self.net_solver_type}")

        if self.verbose:
            print(f"\r[{self.name}-{self.n_layers}] Fitting model: done"
                  .ljust(80))

        return self
 Fit the parameters of the network. 
Fit the parameters of the network.
Fit the parameters of the network .
def _fit_all_network_batch_gradient_descent(self, x, lbda):
        if self.net_solver_type == 'one_shot':
            params = self.get_params_to_learn(up_to_layer=self.n_layers)
            self._fit_sub_net_batch_gd(
                x, lbda, params, self.n_layers, self.max_iter,
                output_layer=self.n_layers
            )
        elif self.net_solver_type == 'recursive':
            layers = range(self.train_from, self.n_layers + 1)
            max_iters = np.diff(np.linspace(0, self.max_iter, len(layers) + 1,
                                            dtype=int))
            for layer_id, max_iter in zip(layers, max_iters):
                if max_iter == 0:
                    continue
                params = self.get_params_to_learn(up_to_layer=layer_id)
                self._fit_sub_net_batch_gd(x, lbda, params, layer_id, max_iter,
                                           output_layer=layer_id)
        elif self.net_solver_type == 'greedy':
            layers = range(1, self.n_layers + 1)
            max_iters = np.diff(np.linspace(0, self.max_iter, self.n_layers+1,
                                            dtype=int))
            for layer_id, max_iter in zip(layers, max_iters):
                if max_iter == 0:
                    continue
                params = self.get_params_to_learn(up_to_layer=layer_id)
                self._fit_sub_net_batch_gd(x, lbda, params, layer_id, max_iter,
                                           output_layer=self.n_layers)
        else:
            raise ValueError(f"net_solver_type should belong to "
                             f"['recursive', 'one_shot', 'greedy']"
                             f", got {self.net_solver_type}")
        if self.verbose:
            print(f"\r[{self.name}-{self.n_layers}] Fitting model: done"
                  .ljust(80))
        return self
def _fit_all_network_batch_gradient_descent ( self , x , lbda ) : if self . net_solver_type == 'one_shot' : params = self . get_params_to_learn ( up_to_layer = self . n_layers ) self . _fit_sub_net_batch_gd ( x , lbda , params , self . n_layers , self . max_iter , output_layer = self . n_layers ) elif self . net_solver_type == 'recursive' : layers = range ( self . train_from , self . n_layers + 1 ) max_iters = np . diff ( np . linspace ( 0 , self . max_iter , len ( layers ) + 1 , dtype = int ) ) for layer_id , max_iter in zip ( layers , max_iters ) : if max_iter == 0 : continue params = self . get_params_to_learn ( up_to_layer = layer_id ) self . _fit_sub_net_batch_gd ( x , lbda , params , layer_id , max_iter , output_layer = layer_id ) elif self . net_solver_type == 'greedy' : layers = range ( 1 , self . n_layers + 1 ) max_iters = np . diff ( np . linspace ( 0 , self . max_iter , self . n_layers + 1 , dtype = int ) ) for layer_id , max_iter in zip ( layers , max_iters ) : if max_iter == 0 : continue params = self . get_params_to_learn ( up_to_layer = layer_id ) self . _fit_sub_net_batch_gd ( x , lbda , params , layer_id , max_iter , output_layer = self . n_layers ) else : raise ValueError ( f"net_solver_type should belong to " f"['recursive', 'one_shot', 'greedy']" f", got {self.net_solver_type}" ) if self . verbose : print ( f"\r[{self.name}-{self.n_layers}] Fitting model: done" . ljust ( 80 ) ) return self
Fit the parameters of the network.
Fit the parameters of the network .
""" Fit the parameters of the network. """
self
x
lbda