matlab 的tenmat函数

1.tenmat函数:

tenmat  Store tensor as a matrix.

tenmat函数将张量存储为矩阵形式,也就是张量展开成矩阵。

2.解析 

a为3*4*5的张量

tenmat(a,1)将张量存储为3*[4*5]的矩阵格式。

tenmat(a,2)将张量存储为4*[3*5]的矩阵格式。

tenmat(a,3)将张量存储为5*[3*4]的矩阵格式。

3.例子

>>a=tensor(rand(12,1),[3,2,2])%随机生成一个3*2*2的张量
a is a tensor of size 3 x 2 x 2
a(:,:,1) = 
    0.6105    0.3864
    0.9049    0.7484
    0.2277    0.8922
a(:,:,2) = 
    0.4098    0.0444
    0.4421    0.1464
    0.7441    0.9583
>> tenmat(a,1)
ans is a matrix corresponding to a tensor of size 3 x 2 x 2
ans.rindices = [ 1 ] (modes of tensor corresponding to rows)
ans.cindices = [ 2  3 ] (modes of tensor corresponding to columns)
ans.data = 
    0.6105    0.3864    0.4098    0.0444
    0.9049    0.7484    0.4421    0.1464
    0.2277    0.8922    0.7441    0.9583

令a(:,:,1)=a1, a(:,:,2)=a2, 则函数tenmat(a,1)将张量a表示为[a1,a2].

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值