Tensor Toolbox手册.docx_第1页
Tensor Toolbox手册.docx_第2页
Tensor Toolbox手册.docx_第3页
Tensor Toolbox手册.docx_第4页
Tensor Toolbox手册.docx_第5页
已阅读5页,还剩11页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Tensor Toolbox for dense, sparse, and decomposed n-way arrays.cp_als - Compute a CP decomposition of any type of tensor.ALS交替最小二乘法求张量CP分解 P = CP_ALS(X,R)计算张量X秩为R的最佳近似CP分解,P=P.lambda, P.U P = CP_ALS(X,R,param,value,.)选择参数设置 tol - Tolerance on difference in fit 1.0e-4 maxiters - Maximum number of iterations 50 dimorder - Order to loop through dimensions 1:ndims(A) init - Initial guess random|nvecs|cell array printitn - Print fit every n iterations; 0 for no printing 1 P,U0,out = CP_ALS(.) also returns additional output that contains the input parameters.Note: The fit is defined as 1 - norm(X-full(P)/norm(X) and is loosely the proportion of the data described by the CP model, i.e., a fit of 1 is perfect.% Examples:% X = sptenrand(5 4 3, 10);% P = cp_als(X,2);% P = cp_als(X,2,dimorder,3 2 1);% P = cp_als(X,2,dimorder,3 2 1,init,nvecs);% U0 = rand(5,2),rand(4,2),; %- Initial guess for factors of P% P,U0,out = cp_als(X,2,dimorder,3 2 1,init,U0);% P = cp_als(X,2,out.params); %- Same params as previous run交替泊松回归求张量X的非负CP分解cp_apr - Compute nonnegative CP with alternating Poisson regression. M = CP_APR(X, R) computes an estimate of the best rank-R M = CP_APR(X, R, param, value, .) specifies optional parameters and values. Valid parameters and their default values are: tol - Tolerance on the inner KKT violation 1.0e-4 maxiters - Maximum number of iterations 1000 maxinneriters = Maximum number of inner iterations 10 init - Initial guess random|ktensor epsilon - parameter to avoid divide by zero 100*eps kappatol - tolerance on complementary slackness 100*eps kappa - offset to fix complementary slackness 10*eps printitn - Print every n outer iterations; 0 for no printing 1 printinneritn - Print every n inner iterations 0 M,M0 = CP_APR(.) also returns the initial guess. M,M0,out = CP_APR(.) also returns additional output. out.kktViolations - maximum kkt violation per iteration out.nInnerIters - number of inner iterations per iteration out.nViolations - number of factor matrices needing complementary slackness adjustment per iteration out.nTotalIters - total number of inner iterations乘数更新求非负CP分解cp_nmu - Compute nonnegative CP with multiplicative updates.cp_opt - Fits a CP model to a tensor via optimization. cp_wopt - Fits a weighted CP model to a tensor via optimization. create_guess - Creates initial guess for CP or Tucker fitting. create_problem - Create test problems for tensor factorizations. export_data - Export tensor-related data to a file. import_data - Import tensor-related data to a file.khatrirao - Khatri-Rao product of matrices. Y=khatrirao(A,B) 计算具有相同列数的矩阵A和B的khatri-rao积 KRON(A(:,1),B(:,1) . KRON(A(:,n),B(:,n) khatrirao(A1,A2,.) computes the Khatri-Rao product of multiple matrices that have the same number of columns. khatrirao(C) computes the Khatri-Rao product of the matrices in cell array C. khatrirao(.,r) computes the Khatri-Rao product in reverse order.% Examples A = rand(5,2); B = rand(3,2); C = rand(2,2); khatrirao(A,B) %- Khatri-Rao of A and B khatrirao(B,A,r) %- same thing as above khatrirao(C,B,A) %- passing a cell array khatrirao(A,B,C,r) %- same as above parafac_als - Deprecated. Use CP_ALS instead. sptendiag - Creates a sparse tensor with v on the diagonal.构造稀疏均匀分布随机张量 sptenrand - Sparse uniformly distributed random tensor. R=sptenrand(sz,density) creates a random sparse tensor of the specified sz with approximately density*prod(sz) nonzero entries. R = sptanrand(sz,nz) creates a random sparse tensor of the specified sz with approximately nz nonzero entries.% Example: R = sptenrand(5 4 2,12); sshopm - Shifted power method for finding a real eigenpair of a real tensor. sshopmc - Shifted power method for real/complex eigenpair of a real tensor. tendiag - Creates a tensor with v on the diagonal. teneye - Create identity tensor of specified size. tenones - Ones tensor. tenrand - Uniformly distributed pseudo-random tensor. tenzeros - Create zeros tensor.HOOI算法做张量Tucker分解 tucker_als - Higher-order orthogonal iteration. T=TUCKER_ALS(X,R) computes the best rank-(R1,R2,.,Rn) approximation of tensor X, according to the specified dimensions in vector R. The input X can be a tensor, sptensor, ktensor, or ttensor. The result returned in T is a ttensor. T=TUCKER_ALS(X,R,param,value,.) specifies optional parameters and values. Valid parameters and their default values are: tol - Tolerance on difference in fit 1.0e-4 maxiters - Maximum number of iterations 50 dimorder - Order to loop through dimensions 1:ndims(A) init - Initial guess random|nvecs|cell array printitn - Print fit every n iterations 1T,U0 = TUCKER_ALS(.) also returns the initial guess.% Examples:% X = sptenrand(5 4 3, 10);% T = tucker_als(X,2); %- best rank(2,2,2) approximation % T = tucker_als(X,2 2 1); %- best rank(2,2,1) approximation % T = tucker_als(X,2,dimorder,3 2 1);% T = tucker_als(X,2,dimorder,3 2 1,init,nvecs);% U0 = rand(5,2),rand(4,2),; %=) for tensors. gt - Greater than () for tensors. innerprod - Efficient inner product with a tensor. isequal - for tensors. issymmetric - Verify that a tensor X is symmetric in specified modes. ldivide - Left array divide for tensor. le - Less than or equal (=) for tensor. lt - Less than () for tensor. minus - Binary subtraction (-) for tensors. mldivide - Slash left division for tensors. mrdivide - Slash right division for tensors. mtimes - tensor-scalar multiplication. mttkrp - Matricized tensor times Khatri-Rao product for tensor.张量阶数ndims - Return the number of dimensions of a tensor. ne - Not equal (=) for tensors. nnz - Number of nonzeros for tensors. 张量F范数norm - Frobenius norm of a tensor. not - Logical NOT () for tensors. nvecs - Compute the leading mode-n vectors for a tensor. or - Logical OR (|) for tensors. permute - Permute tensor dimensions. plus - Binary addition (+) for tensors. power - Elementwise power (.) operator for a tensor. rdivide - Right array divide for tensors. reshape - Change tensor size. scale - Scale along specified dimensions of tensor. size - Tensor dimensions. squeeze - Remove singleton dimensions from a tensor. subsasgn - Subscripted assignment for a tensor. subsref - Subscripted reference for tensors. symmetrize - Symmetrize a tensor X in specified modes. tenfun - Apply a function to each element in a tensor. tensor - Create tensor.张量Hadamard积(.*)times - Array multiplication for tensors.张量装置 transpose - is not defined on tensors.张量d维度乘积ttm - Tensor times matrix. Y = TTM(X,A,N) computes the n-mode product of tensor X with a matrix A; i.e., X x_N A. The integer N specifies the dimension (or mode) of X along which A should be multiplied. If size(A) =J,I, then X must have size(X,N) = I. The result will be the same order and size as X except that size(Y,N) = J. Y = TTM(X,A,B,C,.) computes the n-mode product of tensor X with a sequence of matrices in the cell array. The n-mode products are computed sequentially along all dimensions (or modes) of X. The cell array contains ndims(X) matrices. Y = TTM(X,A,B,C,.,DIMS) computes the sequence tensor-matrix products along the dimensions specified by DIMS. Y = TTM(.,t) performs the same computations as above except the matrices are transposed.% Examples% X = tensor(rand(5,3,4,2);% A = rand(4,5); B = rand(4,3); C = rand(3,4); D = rand(3,2);% Y = ttm(X, A, 1) %- computes X times A in mode-1% Y = ttm(X, A,B,C,D, 1) %- same as above% Y = ttm(X, A, 1, t) %- same as above% Y = ttm(X, A,B,C,D, 1 2 3 4) %- 4-way multiply% Y = ttm(X, D,C,B,A, 4 3 2 1) %- same as above% Y = ttm(X, A,B,C,D) %- same as above% Y = ttm(X, A,B,C,D, t) %- same as above% Y = ttm(X, C,D, 3 4) %- X times C in mode-3 & D in mode-4% Y = ttm(X, A,B,C,D, 3 4) %- same as above% Y = ttm(X, A,B,D, 1 2 4) %- 3-way multiply% Y = ttm(X, A,B,C,D, 1 2 4) %- same as above% Y = ttm(X, A,B,D, -3) %- same as above% Y = ttm(X, A,B,C,D, -3) %- same as above ttsv - Tensor times same vector in multiple modes.张量与张量的乘积(用于计算外积、内积、缩并)ttt - Tensor mulitplication (tensor times tensor).张量的外积 TTT(X,Y) computes the outer product of tensors X and Y.张量的缩并或者内积 TTT(X,Y,XDIMS,YDIMS) computes the contracted product of tensors X and Y in the dimensions specified by the row vectors XDIMS and YDIMS. The sizes of the dimensions specified by XDIMS and YDIMS must match; that is, size(X,XDIMS) must equal size(Y,YDIMS). 张量的缩并或者内积 TTT(X,Y,DIMS) computes the inner product of tensors X and Y in the dimensions specified by the vector DIMS. The sizes of the dimensions specified by DIMS must match; that is, size(X,DIMS) must equal size(Y,DIMS). % Examples% X = tensor(rand(4,2,3);% Y = tensor(rand(3,4,2);% Z = ttt(X,Y) %- outer product of X and Y% Z = ttt(X,X,1:3) %- inner product of X with itself% Z = ttt(X,Y,1 2 3,2 3 1) %- inner product of X & Y% Z = ttt(X,Y,1 3,2 1) %- product of X & Y along specified dims张量与向量乘积 ttv - Tensor times vector. Y = TTV(X,A,N) computes the product of tensor X with a (column) vector A. The integer N specifies the dimension in X along which A is multiplied. If size(A) = I,1, then X must have size(X,N) = I. Note that ndims(Y) = ndims(X) - 1 because the N-th dimension is removed. Y = TTV(X,A,B,C,.) computes the product of tensor X with a sequence of vectors in the cell array. The products are computed sequentially along all dimensions (or modes) of X. The cell array contains ndims(X) vectors. Y = TTV(X,A,B,C,.,DIMS) computes the sequence of tensor-vector products along the dimensions specified by DIMS.% Examples% X = tensor(rand(5,3,4,2);% A = rand(5,1); B = rand(3,1); C = rand(4,1); D = rand(2,1);% Y = ttv(X, A, 1) %- X times A in mode 1% Y = ttv(X, A,B,C,D, 1) %- same as above% Y = ttv(X, A,B,C,D, 1 2 3 4) %- All-mode multiply% Y = ttv(X, D,C,B,A, 4 3 2 1) %- same as above% Y = ttv(X, A,B,C,D) %- same as above% Y = ttv(X, C,D, 3 4) %- X times C in mode-3 & D in mode-4% Y = ttv(X, A,B,C,D, 3 4) %- same as above% Y = ttv(X, A,B,D, 1 2 4) %- 3-way mutplication% Y = ttv(X, A,B,C,D, 1 2 4) %- same as above% Y = ttv(X, A,B,D, -3) %- same as above% Y = ttv(X, A,B,C,D, -3) %- same as above uminus - Unary minus (-) for tensors. uplus - Unary plus (+) for tensors. xor - Logical EXCLUSIVE OR for tensors.SPTENSOR and - Logical AND (&) for sptensors. collapse - Collapse sparse tensor along specified dimensions. contract - Contract sparse tensor along two dimensions (array trace). ctranspose - is not defined for sparse tensors. disp - Command window display of a sparse tensor. display - Command window display of a sparse tensor. divide - Divide an SPTENSOR by a nonnegative KTENSOR. double - Converts a sparse tensor to a dense multidimensional array. elemfun - Manipulate the nonzero elements of a sparse tensor. end - Last index of indexing expression for sparse tensor. eq - Equal (=) for sptensors. find - Find subscripts of nonzero elements in a sparse tensor. full - Convert a sparse tensor to a (dense) tensor. ge - Greater than or equal for sptensors. gt - Greater than for sptensors. innerprod - Efficient inner product with a sparse tensor. isequal - for sptensors. ldivide - Array right division for sparse tensors. le - Less than or equal for sptensors. lt - Less than for sptensors. minus - Binary subtraction for sparse tensors. mldivide - Slash left division for sparse tensors. mrdivide - Slash right division for sparse tensors. 张量与标量乘积mtimes - sptensor-scalar multiplication. mttkrp - Matricized tensor times Khatri-Rao product for sparse tensor. ndims - Number of dimensions of a sparse tensor. ne - Not equal (=) for sptensors. nnz - Number of nonzeros in sparse tensor. norm - Frobenius norm of a sparse tensor. not - Logical NOT () for sptensors. nvecs - Compute the leading mode-n vectors for a sparse tensor. ones - Replace nonzero elements of sparse tensor with ones. or - Logical OR (|) for sptensors. permute - Rearrange the dimensions of a sparse tensor. plus - Binary addition for sparse tensors. rdivide - Array right division for sparse tensors. reshape - Reshape sparse tensor. scale - Scale along specified dimensions for sparse tensors. size - Sparse tensor dimensions. spmatrix - Converts a two-way sparse tensor to sparse matrix. sptensor - Create a sparse tensor. squeeze - Remove singleton dimensions from a sparse tensor. subsasgn - Subscripted assignment for sparse tensor. subsref - Subscripted reference for a sparse tensor. times - Array multiplication for sparse tensors. transpose - is not defined on sparse tensors. ttm - Sparse tensor times matrix. ttt - Sparse tensor times sparse tensor. ttv - Sparse tensor times vector. uminus - Unary minus (-) for sptensor. uplus - Unary plus (+) for sptensor. xor - Logical XOR for sptensors.TTENSOR disp - Command window display of a ttensor. display - Command window display of a ttensor. double - Convert ttensor to double array. end - Last index of indexing expression for ttensor. full - Convert a ttensor to a (dense) tensor. innerprod - Efficient inner product with a ttensor. isequal - True if each component of two ttensors is numerically equal. mtimes - Implement scalar multiplication for a ttensor. mttkrp - Matricized tensor times Khatri-Rao product for ttensor. ndims - Return the number of dimensions for a ttensor. norm - Norm of a ttensor. nvecs - Compute the leading mode-n vectors for a ttensor. permute - Permute dimensions for a ttensor. size - Size of a ttensor. subsasgn - Subscripted reference for a ttensor. subsref - Subscripted reference for a ttensor. ttensor - Tensor stored as a Tucker operator (decomposed). ttm - Tensor times matrix for ttensor. ttv - Tensor times vector for ttensor. uminus - Unary minus for ttensor. uplus - Unary plus for ttensor.KTENSOR arrange - Arranges the rank-1 components of a ktensor. datadisp - Special display of a ktensor. disp - Command window display for a ktensor. display - Command window display for a ktensor. double - Convert a ktensor to a double array. end - Last index of indexing expression for ktensor. extract - Creates a new ktensor with only the specified components. fixsigns - Fix sign ambiguity of a ktensor. full - Convert a ktensor to a (dense) tensor. innerprod - Efficient inner product with a ktensor. isequal - True if each component of two ktensors is numerically equal. ktensor - Tensor stored as a Kruskal operator (decomposed). minus - Binary subtraction for ktensor. mtimes - Implement A*B (scalar multiply) for ktensor. mttkrp - Matricized tensor times Khatri-Rao product for ktensor. ncomponents - Number of components for a ktensor. ndims - Number of dimensions for a ktensor. norm - Frobenius norm of a ktensor. normalize - Normalizes the columns of the factor matrices. nvecs - Compute the leading mode-n vectors for a ktensor. permute - Permute dimensions of a ktensor. plus - Binary addition for ktensor. redistribute - Distribute lambda values to a specified mode. score - Checks if two ktensors match except for permutation. size - Size of ktensor. subsasgn - Subscripted assignement for ktensor. subsref - Subscripted reference for a ktensor. times - Element-wise multiplication for ktensor. tocell - Convert X to a

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论