def __init__(self, factors):
        """Initializes KTensor.

        Parameters
        ----------
        factors : list of ndarray
            Factor matrices.
        """

        self.factors = factors
        self.shape = tuple([f.shape[0] for f in factors])
        self.ndim = len(self.shape)
        self.size = np.prod(self.shape)
        self.rank = factors[0].shape[1]

        for f in factors[1:]:
            if f.shape[1] != self.rank:
                raise ValueError('Tensor factors have inconsistent rank.')
def __init__ ( self , factors ) : self . factors = factors self . shape = tuple ( [ f . shape [ 0 ] for f in factors ] ) self . ndim = len ( self . shape ) self . size = np . prod ( self . shape ) self . rank = factors [ 0 ] . shape [ 1 ] for f in factors [ 1 : ] : if f . shape [ 1 ] != self . rank : raise ValueError ( 'Tensor factors have inconsistent rank.' )
Initializes KTensor.

        Parameters
        ----------
        factors : list of ndarray
            Factor matrices.