Returns the context of a tensor

Creates a dictionary of the parameters characterising the tensor
Parameters:tensor : tensorly.tensor
Returns:context : dict


>>> import tensorly as tl
Using numpy backend.

Imagine you have an existing tensor tensor:

>>> import numpy as np
>>> tensor = tl.tensor([0, 1, 2], dtype=np.float32)

The context, here, will simply be the dtype:

>>> tl.context(tensor)
{'dtype': dtype('float32')}

Note that, if you were using, say, PyTorch, the context would also include the device (i.e. CPU or GPU) and device ID.

If you want to create a new tensor in the same context, use this context:

>>> new_tensor = tl.tensor([1, 2, 3], **tl.context(tensor))