Free Tensors

What are free tensors

Free tensors live in a tensor algebra. Equipped with addition, scalar multiplication and a tensor product, a tensor algebra is a real, non-commutative unital algebra, with unit \(\mathbb{1} = (1, 0, 0, ...)\). It is within the tensor algebra that the signature of a path lives.

For a more accurate defnintion of the tensor algebra, see Lyons and McLeod [LM24]. See also Reutenauer [Reu93] and Bourbaki [Bou98].

How do free tensors fit into RoughPy

You will most commonly encounter free tensors by taking the signature of a stream.

How to work with free tensors

We can create a free tensor in many ways using RoughPy.

We create a free tensor using data, a Width and a Depth. The data you use can take many forms, here are some example constructors:

from roughpy import FreeTensor

tensor1 = FreeTensor([0., 1., 2., 3.], width=3, depth=2)

tensor2 = FreeTensor([0, 1, 2, 3], width=3, depth=2)

tensor3 = FreeTensor((1, 1.0), width=2, depth=2)

k1 = TensorKey(1, width=2, depth=2)
tensor4 = FreeTensor((k1, 1.0), width=2, depth=2)

data = [
    {1: 1., 2: 2.},
    {0: 1., 2: 1.}
    ]
tensor5 = FreeTensor(data, width=2, depth=2)

You can do arithmetic with free tensors. We can add, subtract, multiply and divide them

t1 = FreeTensor(data1, width=width, depth=depth)
t2 = FreeTensor(data2, width=width, depth=depth)

tensors_sum = t1+t2
# should be the same as FreeTensor(data1 + data2, width=width, depth=depth)

tensors_difference = t1-t2
# should be the same as FreeTensor(data1 - data2, width=width, depth=depth)

tensors_multiplied = t1 * t2

tensor_scalar_multiplied =  t1 * 2.0
# should be the same as FreeTensor(2.0 * data1, width=width, depth=depth)

tensor_scalar_divided = t1 / 2.0
# should be the same as FreeTensor(data1 / 2.0, width=width, depth=depth)

as well as take their exponential, log, and antipode.

# exponential
t1.exp()

#log
t1.log()

# antipode
t1.antipode()

Literature references

[Bou98]

N. Bourbaki. Algebra I: Chapters 1-3. Springer Science & Business Media, August 1998. ISBN 978-3-540-64243-5. Google-Books-ID: STS9aZ6F204C.

[Bou89]

Nicolas Bourbaki. Lie Groups and Lie Algebras: Chapters 1-3. Springer Science & Business Media, 1989. ISBN 978-3-540-64242-8. Google-Books-ID: brSYF_rB2ZcC.

[KMFL20]

Patrick Kidger, James Morrill, James Foster, and Terry Lyons. Neural Controlled Differential Equations for Irregular Time Series. November 2020. arXiv:2005.08926 [cs, stat]. URL: http://arxiv.org/abs/2005.08926 (visited on 2023-12-08), doi:10.48550/arXiv.2005.08926.

[LM24]

Terry Lyons and Andrew D. McLeod. Signature Methods in Machine Learning. January 2024. arXiv:2206.14674 [cs, math, stat]. URL: http://arxiv.org/abs/2206.14674 (visited on 2024-02-14).

[LCL07]

Terry J. Lyons, Michael J. Caruana, and Thierry Lévy. Differential Equations Driven by Rough Paths: Ecole d’Eté de Probabilités de Saint-Flour XXXIV-2004. Springer, April 2007. ISBN 978-3-540-71285-5. Google-Books-ID: hOm5BQAAQBAJ.

[Reu93]

Christophe Reutenauer. Free Lie Algebras. Clarendon Press, 1993. ISBN 978-0-19-853679-6. Google-Books-ID: cBvvAAAAMAAJ.