用numpy计算协方差矩阵

时间:2020-02-14 16:20:33

标签: python numpy mnist

我有以下情况:

我先加载mnist数据,然后再计算前500个样本的协方差矩阵。

traind, testd, trainl, testl = np.load(open("mnist.npz","rb")).values()

first500 = traind[0:500]
covariancematrix = first500.reshape(500,-1,1)*first500.reshape(500,1,-1)

这将为我提供每个样本的协方差矩阵,所以我有500x784x784。

我现在的问题是,我可以使用给定的np.outer函数的numpy吗?

0 个答案:

没有答案