Tensor reshaping

From testwiki
Jump to navigation Jump to search

Template:More citations needed In multilinear algebra, a reshaping of tensors is any bijection between the set of indices of an order-M tensor and the set of indices of an order-L tensor, where L<M. The use of indices presupposes tensors in coordinate representation with respect to a basis. The coordinate representation of a tensor can be regarded as a multi-dimensional array, and a bijection from one set of indices to another therefore amounts to a rearrangement of the array elements into an array of a different shape. Such a rearrangement constitutes a particular kind of linear map between the vector space of order-M tensors and the vector space of order-L tensors.

Definition

Given a positive integer M, the notation [M] refers to the set {1,,M} of the first Template:Mvar positive integers.

For each integer m where 1mM for a positive integer M, let Vm denote an Im-dimensional vector space over a field F. Then there are vector space isomorphisms (linear maps)

V1VMFI1FIMFIπ1FIπMFIπ1Iπ2FIπ3FIπMFIπ1Iπ3FIπ2FIπ4FIπMFI1I2IM,

where π𝔖M is any permutation and 𝔖M is the symmetric group on M elements. Via these (and other) vector space isomorphisms, a tensor can be interpreted in several ways as an order-L tensor where LM.

Coordinate representation

The first vector space isomorphism on the list above, V1VMFI1FIM, gives the coordinate representation of an abstract tensor. Assume that each of the M vector spaces Vm has a basis {v1m,v2m,,vImm}. The expression of a tensor with respect to this basis has the form π’œ=i1=1I1iM=1IMai1,i2,,iMvi11vi22viMM, where the coefficients ai1,i2,,iM are elements of F. The coordinate representation of π’œ is i1=1I1iM=1IMai1,i2,,iM𝐞i11𝐞i22𝐞iMM,where 𝐞im is the ith standard basis vector of FIm. This can be regarded as a M-way array whose elements are the coefficients ai1,i2,,iM.

General flattenings

For any permutation π𝔖M there is a canonical isomorphism between the two tensor products of vector spaces V1V2VM and Vπ(1)Vπ(2)Vπ(M). Parentheses are usually omitted from such products due to the natural isomorphism between Vi(VjVk) and (ViVj)Vk, but may, of course, be reintroduced to emphasize a particular grouping of factors. In the grouping, (Vπ(1)Vπ(r1))(Vπ(r1+1)Vπ(r2))(Vπ(rL1+1)Vπ(rL)), there are L groups with rlrl1 factors in the lth group (where r0=0 and rL=M).

Letting Sl=(π(rl1+1),π(rl1+2),,π(rl)) for each l satisfying 1lL, an (S1,S2,,SL)-flattening of a tensor π’œ, denoted π’œ(S1,S2,,SL), is obtained by applying the two processes above within each of the L groups of factors. That is, the coordinate representation of the lth group of factors is obtained using the isomorphism (Vπ(rl1+1)Vπ(rl1+2)Vπ(rl))(FIπ(rl1+1)FIπ(rl1+2)FIπ(rl)), which requires specifying bases for all of the vector spaces Vk. The result is then vectorized using a bijection μl:[Iπ(rl1+1)]×[Iπ(rl1+2)]××[Iπ(rl)][ISl] to obtain an element of FISl, where ISl:=i=rl1+1rlIπ(i), the product of the dimensions of the vector spaces in the lth group of factors. The result of applying these isomorphisms within each group of factors is an element of FIS1FISL, which is a tensor of order L.

Vectorization

By means of a bijective map μ:[I1]××[IM][I1IM], a vector space isomorphism between FI1FIM and FI1IM is constructed via the mapping 𝐞i11𝐞imm𝐞iMM𝐞μ(i1,i2,,iM), where for every natural number i such that 1iI1IM, the vector 𝐞i denotes the ith standard basis vector of Fi1iM. In such a reshaping, the tensor is simply interpreted as a vector in FI1IM. This is known as vectorization, and is analogous to vectorization of matrices. A standard choice of bijection μ is such that

vec(π’œ)=[a1,1,,1a2,1,,1an1,1,,1a1,2,1,,1aI1,I2,,IM]T,

which is consistent with the way in which the colon operator in Matlab and GNU Octave reshapes a higher-order tensor into a vector. In general, the vectorization of π’œ is the vector [aμ1(i)]i=1I1IM.

The vectorization of π’œ denoted with vec(π’œ) or π’œ[:] is an [S1,S2]-reshaping where S1=(1,2,,M) and S2=.

Mode-m Flattening / Mode-m Matrixization

Let π’œFI1FI2FIM be the coordinate representation of an abstract tensor with respect to a basis. Mode-m matrixizing (a.k.a. flattening) of π’œ is an [S1,S2]-reshaping in which S1=(m) and S2=(1,2,,m1,m+1,,M). Usually, a standard matrixizing is denoted by

𝐀[m]=π’œ[S1,S2]

This reshaping is sometimes called matrixizing, matricizing, flattening or unfolding in the literature. A standard choice for the bijections μ1, μ2 is the one that is consistent with the reshape function in Matlab and GNU Octave, namely

𝐀[m]:=[a1,1,,1,1,1,,1a2,1,,1,1,1,,1aI1,I2,,Im1,1,Im+1,,IMa1,1,,1,2,1,,1a2,1,,1,2,1,,1aI1,I2,,Im1,2,Im+1,,IMa1,1,,1,Im,1,,1a2,1,,1,Im,1,,1aI1,I2,,Im1,Im,Im+1,,IM]

Definition Mode-m Matrixizing:[1] [𝐀[m]]jk=ai1imiM, where j=im and k=1+n=0nmM(in1)l=0lmn1Il. The mode-m matrixizing of a tensor π’œFI1×...IM, is defined as the matrix 𝐀[m]FIm×(I1Im1Im+1IM). As the parenthetical ordering indicates, the mode-m column vectors are arranged by sweeping all the other mode indices through their ranges, with smaller mode indexes varying more rapidly than larger ones; thus

References

Template:Reflist