Advanced maths

Tensor train decomposition calculator with TT ranks and reconstruction error

Represent an ordered small tensor as a chain of low-rank cores using sequential singular-value truncation.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Represent an ordered small tensor as a chain of low-rank cores using sequential singular-value truncation.

THE FORMULAA(i1,...,id) ≈ G1(i1) G2(i2) ... Gd(id); ||A−ATT||F² ≤ sum discarded singular values²

A worked example

The 2×2×2 tensor with flattened entries 1,2,2,4,2,4,4,8 is the outer product of three copies of (1,2). Every TT bond rank is one and its exact reconstruction error is zero.

Good to know

Order3–6 tensor, each dimension2–5, at most4000 entries; supplied truncation tolerance or rank caps. Sequential TT-SVD with squared discarded singular-value bound and explicit ordering. Numerical rank tolerances stated; no globally best fixed-TT-rank guarantee.

A chain rather than rank-one summands

A tensor train stores the entries of a multidimensional array through a sequence of three-index cores. The neighboring auxiliary indices are called bonds, and their sizes are the TT ranks. Multiplying the core slices along those bonds reconstructs one array entry for a chosen tuple of physical indices.

This differs from a CP decomposition, which adds a collection of full rank-one outer products. It also differs from simply reporting mode-unfolding ranks: those ranks describe matrices but do not supply the chain cores. Tensor order is part of the representation, because moving a physical axis can change the ranks across the successive train cuts.

Tensor train decomposition with TT ranks and reconstruction errorG1G2G311Outer product: all bond ranks = 1
Scroll across to see the full diagram.
The 2×2×2 tensor with flattened entries 1,2,2,4,2,4,4,8 is the outer product of three copies of (1,2). Every TT bond rank is one and its exact reconstruction error is zero.

Compare this with the CP tensor decomposition calculator for a three dimensional array. Factor an ordered tensor into a chain of three-index cores with TT bond ranks. CP produces a sum of rank-one outer products and multilinear ranks alone do not construct this chain.

Preparing the array and its ordering

Supply a dimension list and exactly its product in scalar entries. The flattened convention has the last physical index varying fastest. The same numbers interpreted with another indexing convention describe a different tensor, so the calculator must preserve this convention consistently in unfolding, core construction and dense reconstruction.

The initial domain caps tensor order, axis sizes and total entries to make the complete input and reconstructed array inspectable. These limits are not mathematical restrictions on tensor trains themselves. Nonfinite values and an entry count inconsistent with the declared shape are invalid data, rather than reasons to infer a missing dimension or silently fill unspecified entries with zeros.

How TT-SVD constructs the cores

At the first cut, reshape the array into a matrix whose row index is the first physical coordinate. A singular-value decomposition identifies the retained left singular vectors, which become the first core. Multiply the retained singular values into the right factor, reshape that factor for the next physical coordinate, and repeat.

At an intermediate step, the row index combines the preceding bond with the current physical coordinate. This explains why the core has a left bond, a physical index and a right bond. The final core absorbs the remaining factor. Each unfolding and reshaping must be documented, because an incorrect axis permutation can still produce apparently sensible singular values while reconstructing the wrong array.

Tolerance, rank caps and the error bound

Discarding singular values creates an approximation. Their squared magnitudes provide a cumulative Frobenius error bound for the sequential TT-SVD construction. A relative tolerance must be interpreted against the Frobenius norm of the complete input, with a stated rule for allocating the allowed squared error across the train cuts.

A supplied maximum bond rank can force more truncation than the requested tolerance permits. Report that conflict using the measured reconstruction error and discarded-energy bound. Do not label the tolerance satisfied merely because every rank stayed under its cap. TT-SVD is a constructive approximation with a useful bound, not a proof of the globally best approximation at all selected bond ranks.

The rank-one default tensor

The default entries are products of three independent factors, each containing one and two. Across any cut between physical coordinates, the corresponding unfolding is an outer product of two vectors and therefore has rank one. No nonzero singular value needs to be discarded when a bond rank of at least one is allowed.

One possible train uses the three factor vectors directly with bond dimensions one. Actual SVD cores may contain different signs or normalizations, because those factors can be moved between neighboring cores without changing the tensor. Compare the reconstructed eight entries, not the individual core values. Exact mathematical error is zero; floating reconstruction should agree to numerical precision.

Compression and gauge freedom

The stored parameter count is the sum of left rank times physical size times right rank over all cores. Compare it with the product of the physical sizes to assess compression. A tensor train can use more parameters than the original array for a small dense tensor or an unfavorable rank choice; compression is not automatic.

Internal gauge freedom permits inserting an invertible matrix on one bond and its inverse on the adjacent core. This can change the entries of both cores while leaving every reconstructed tensor entry fixed. Consequently, core-by-core comparisons are generally inappropriate unless both decompositions use a compatible orthogonality and normalization convention.

Checks that support interpretation

Reconstruct the full small tensor independently and calculate its actual Frobenius error. Compare that error with the discarded singular-value bound. Verify the core dimensions, unit endpoint bonds and consistency of every neighboring bond. For an untruncated decomposition, the dense reconstruction should recover the original array within the stated floating tolerance.

These checks establish the quality of this particular ordered approximation. They do not prove that another axis permutation would not compress better, or that the tensor comes from a specific physical or probabilistic model. Use the displayed cut ranks and singular-value spectra to identify where correlations across the chosen ordering make the chain expensive.

A few questions, answered

Is TT rank the same as CP rank?

No. TT ranks belong to successive unfolding cuts and do not equal the number of CP outer-product summands.

Can reordering axes change compression?

Yes. The ranks across train cuts depend on the chosen physical-axis order.

Why can cores differ between packages?

Signs, scalings and internal gauge transformations can change cores while preserving the reconstructed tensor.

Does a rank cap guarantee the tolerance?

No. Inspect the actual reconstruction error and reported discarded-energy bound.

Find your calculator

Start typing to explore the library.