Esempio n. 1
0
 def mttkrp(self, U, n):
     # Compute the matrix product of the n-mode matricization of self with the KR
     # product of all entries in U, a list of matrices, except the nth one.
     X = self.data
     N = X.ndim
     order = range(N)
     order_sans_n = order[:]; order_sans_n.remove(n)
     Xn = X.transpose([n] + order_sans_n)
     Xn = Xn.reshape(X.shape[n], X.size / X.shape[n])
     Z = tt.khatrirao([U[i] for i in order_sans_n], reverse=True)
     return np.dot(Xn, Z)
Esempio n. 2
0
 def mttkrp(self, U, n):
     # Compute the matrix product of the n-mode matricization of self with the KR
     # product of all entries in U, a list of matrices, except the nth one.
     X = self.data
     N = X.ndim
     order = range(N)
     order_sans_n = order[:]
     order_sans_n.remove(n)
     Xn = X.transpose([n] + order_sans_n)
     Xn = Xn.reshape(X.shape[n], X.size / X.shape[n])
     Z = tt.khatrirao([U[i] for i in order_sans_n], reverse=True)
     return np.dot(Xn, Z)
Esempio n. 3
0
 def full(self):
     # Convert to a full dense tensor.
     A = tt.khatrirao(self.u_list, reverse=True)
     data = np.dot(self.lmbda.T, A.T)
     return tensor.Tensor(data, self.shape())