张量学习笔记 | 用matlab实现HOSVD

本文通过Matlab详细展示了高阶奇异值分解(HOSVD)推荐系统的实现过程,包括张量创建、模展开、奇异值分解及核心张量构建等关键步骤。

实现HOSVD(高阶奇异值分解)推荐系统
​​​​​​https://blog.youkuaiyun.com/zd836614437/article/details/51193359

对上面文章内容用matlab实现

1、创建一个如下的张量

代码:

A(: , : ,1)=[1,0,0;1,0,0;0,0,0];
A(: , : ,2)=[0,0,0;0,1,0;0,0,0];
A(: , : ,3)=[0,0,0;0,0,0;0,0,1];
A=tensor(A)

输出:

A is a tensor of size 3 x 3 x 3
    A(:,:,1) = 
         1     0     0
         1     0     0
         0     0     0
    A(:,:,2) = 
         0     0     0
         0     1     0
         0     0     0
    A(:,:,3) = 
         0     0     0
         0     0     0
         0     0     1

图形如下图:

2、将张量按照mode-n模展开

A1=tenmat(A,1);   %模-1展开
A2=tenmat(A,2);   %模-2展开
A3=tenmat(A,3);  %模-3展开

输出为:

A1 is a matrix corresponding to a tensor of size 3 x 3 x 3
    A1.rindices = [ 1 ] (modes of tensor corresponding to rows)
    A1.cindices = [ 2  3 ] (modes of tensor corresponding to columns)
    A1.data = 
             1     0     0     0     0     0     0     0     0
             1     0     0     0  

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值