TensorSpace

class odl.core.space.base_tensors.TensorSpace(shape, dtype, device, **kwargs)[source]

Bases: LinearSpace

Base class for sets of tensors of arbitrary data type.

A tensor is, in the most general sense, a multi-dimensional array that allows operations per entry (keep the rank constant), reductions / contractions (reduce the rank) and broadcasting (raises the rank). For non-numeric data type like object, the range of valid operations is rather limited since such a set of tensors does not define a vector space. Any numeric data type, on the other hand, is considered valid for a tensor space, although certain operations - like division with integer dtype - are not guaranteed to yield reasonable results.

Under these restrictions, all basic vector space operations are supported by this class, along with reductions based on arithmetic or comparison, and element-wise mathematical functions (“ufuncs”).

See the Wikipedia article on tensors for further details. See also [Hac2012] “Part I Algebraic Tensors” for a rigorous treatment of tensors with a definition close to this one.

Note also that this notion of tensors is the same as in popular Deep Learning frameworks.

References

[Hac2012] Hackbusch, W. Tensor Spaces and Numerical Tensor Calculus. Springer, 2012.

__init__(shape, dtype, device, **kwargs)[source]

Initialize a new instance.

Parameters

shapenonnegative int or sequence of nonnegative ints

Number of entries of type dtype per axis in this space. A single integer results in a space with rank 1, i.e., 1 axis.

dtype :

Data type of elements in this space. Can be provided in any way the numpy.dtype constructor understands, e.g. as built-in type or as a string. For a data type with a dtype.shape, these extra dimensions are added to the left of shape.