nngeometry/object/pspace.py
def solve(self, v, regul=1e-8, impl='solve'):
        """
        solves v = Ax in x
        """
        # TODO: test
        if impl == 'solve':
            # TODO: reuse LU decomposition once it is computed
            inv_v, _ = torch.solve(v.get_flat_representation().view(-1, 1),
                                   self.data +
                                   regul * torch.eye(self.size(0),
                                                     device=self.data.device))
            return PVector(v.layer_collection, vector_repr=inv_v[:, 0])
        elif impl == 'eigendecomposition':
            v_eigenbasis = self.project_to_diag(v)
            inv_v_eigenbasis = v_eigenbasis / (self.evals + regul)
            return self.project_from_diag(inv_v_eigenbasis)
        else:
            raise NotImplementedError

        solves v = Ax in x
        
solves v = Ax in x
solves v = Ax in x
def solve(self, v, regul=1e-8, impl='solve'):
        if impl == 'solve':
            inv_v, _ = torch.solve(v.get_flat_representation().view(-1, 1),
                                   self.data +
                                   regul * torch.eye(self.size(0),
                                                     device=self.data.device))
            return PVector(v.layer_collection, vector_repr=inv_v[:, 0])
        elif impl == 'eigendecomposition':
            v_eigenbasis = self.project_to_diag(v)
            inv_v_eigenbasis = v_eigenbasis / (self.evals + regul)
            return self.project_from_diag(inv_v_eigenbasis)
        else:
            raise NotImplementedError
def solve ( self , v , regul = 1e-8 , impl = 'solve' ) : if impl == 'solve' : inv_v , _ = torch . solve ( v . get_flat_representation ( ) . view ( - 1 , 1 ) , self . data + regul * torch . eye ( self . size ( 0 ) , device = self . data . device ) ) return PVector ( v . layer_collection , vector_repr = inv_v [ : , 0 ] ) elif impl == 'eigendecomposition' : v_eigenbasis = self . project_to_diag ( v ) inv_v_eigenbasis = v_eigenbasis / ( self . evals + regul ) return self . project_from_diag ( inv_v_eigenbasis ) else : raise NotImplementedError
solves v = Ax in x
solves v = Ax in x
"""
        solves v = Ax in x
        """ # TODO: test # TODO: reuse LU decomposition once it is computed
self
v
regul
impl