Can I use numpy for calculating eigenvectors. But I think the problem is that x is not a numpy matrix. It’s a pytorch tensor. So how can I use numpy with pytorch?
import numpy as np
def pca(x):
x = torch.from_numpy(np.cov(x))
ev_s , eig_s = torch.from_numpy(np.linalg.eig(x))
return ev_s , eig_s