A Tensor Train is a type of tensor factorization involving the product of 3-index tensors organized on a one-dimensional chain.
In the context of function approximation and probability, a function of
where, for every choice of
The Tensor Train factorization can be used to parametrize probability distributions, which is the main focus of this package. In this case,
A slight generalization, useful to describe systems with periodic boundary conditions is the following:
In other words, to evaluate
Tensor Trains are the most basic type of Tensor Network. Tensor networks are a large family of tensor factorizations which are often best represented in diagrammatic notation. For this reason, the term bond is used interchangeably as index. The indices
Tensor Trains are used to parametrize wavefunctions in many-body quantum physics. The resulting quantum state is called Matrix Product State. In such context, the entries are generally complex numbers, and a probability can be obtained for a given state by taking the squared absolute value of the wavefunction.
In this package we focus on the "classical" case where the Tensor Train directly represents a probability distribution
Given a Tensor Train some simple recursive strategies can be employed to do the following operations in time
such that
Single-variable
and two-variable
Via hierarchical sampling
by first sampling
This small package provides some utilities for creating, manipulating and evaluating Tensor Trains interpreted as functions, with a focus on the probabilistic side.
Each variable
Common operations are:
-
evaluate
a Tensor Train at a given set of indices -
orthogonalize_left!
,orthogonalize_right!
: bring a Tensor Train to left/right orthogonal form -
compress!
a Tensor Train using SVD-based truncations -
normalize!
a Tensor Train in the probability sense (not in the$L_2$ norm sense!), see above -
sample
from a Tensor Train intended as a probability ditribution, see above -
+
,-
: take the sum/difference of two TensorTrains
Let's construct and initialize at random a Tensor Train of the form
where
using TensorTrains
L = 3 # length
q = (2, 3) # number of values taken by x, y
d = 5 # bond dimension
A = rand_tt(d, L, q...) # construct Tensor Train with random positive entries
xy = [[rand(1:qi) for qi in q] for _ in 1:L] # random set of indices
p = evaluate(A, xy) # evaluate `A` at `xy`
compress!(A; svd_trunc = TruncThresh(1e-8)); # compress `A` to reduce the bond dimension
pnew = evaluate(A, xy)
ε = abs( (p - pnew)/p )
- https://tensornetwork.org: "an open-source review article focused on tensor network algorithms, applications, and software"
- Oseledets, I.V., 2011. Tensor-train decomposition. SIAM Journal on Scientific Computing, 33(5).
- TensorTrains.jl: conceived for the application of Tensor Train decomposition to elliptic PDEs, does not cover anything related to probability
- Tensor-Train-Julia: less lightweight, mostly designed for quantum applications, still WIP
- Itensors.jl: a full-fledged Tensor Network library, mostly designed for quantum applications. Interface is more intuitive, but likely less efficient if all you need to do is simple operations on 1D Tensor Networks