Module vis: visualization methods for tensors¶
Package teneva, module vis: visualization methods for tensors.
This module contains the functions for visualization of TT-tensors.
- teneva_jax.vis.show(Y)[source]¶
Check and display mode size and TT-rank of the given TT-tensor.
- Parameters:
Y (list) – TT-tensor.
Examples:
# 5-dim random TT-tensor with mode size 4 and TT-rank 3: rng, key = jax.random.split(rng) Y = teneva.rand(5, 4, 3, key) # Print the resulting TT-tensor: teneva.show(Y) # >>> ---------------------------------------- # >>> Output: # TT-tensor-jax | d = 5 | n = 4 | r = 3 | #
If an incorrect TT-tensor is passed to the function (the correctness of the shape of all cores is explicitly checked), then an error will be generated:
Y = [] try: teneva.show(Y) except ValueError as e: print('Error :', e) # >>> ---------------------------------------- # >>> Output: # Error : Invalid TT-tensor #
Y = [42.] try: teneva.show(Y) except ValueError as e: print('Error :', e) # >>> ---------------------------------------- # >>> Output: # Error : Invalid TT-tensor #
Y = [ jnp.zeros((1, 5, 7)), jnp.zeros((100, 42, 7, 1)), jnp.zeros((42, 7, 1))] try: teneva.show(Y) except ValueError as e: print('Error :', e) # >>> ---------------------------------------- # >>> Output: # Error : Invalid shape of middle cores for TT-tensor #
import numpy as onp # Numpy is not supported! Y = [ onp.zeros((1, 5, 3)), onp.zeros((100, 3, 5, 3)), onp.zeros((3, 5, 1))] try: teneva.show(Y) except ValueError as e: print('Error :', e) # >>> ---------------------------------------- # >>> Output: # Error : Invalid left core of TT-tensor #
rng, key = jax.random.split(rng) Y = teneva.rand(5, 6, 7, key) try: teneva.show(Y) except ValueError as e: print('Error :', e) # >>> ---------------------------------------- # >>> Output: # Error : TT-rank should be no greater than mode size #