使用python tensorly 实现张量tucker分解

Tucker Decomposition可以看作是张量的PCA(principal components analysis),将一个张量分解为一个核心张量和因子矩阵乘积形式
这里写图片描述

  • 采用tucker函数来进行TD分解,首先需要设定rank
import tensorly as tl
import numpy as np
from tensorly.decomposition import tucker
X = tl.tensor(np.arange(24).reshape(3, 4, 2))
core, factors = tucker(X, rank=[3, 4, 2])
  • 查看分解之后的结果,核心张量和维度
print(core)
print(core.shape)

这里写图片描述

  • 比较还原之后的张量与原始张量的区别
    这里写图片描述

猜你喜欢

转载自blog.csdn.net/weixin_36372879/article/details/80771786