layers.tensor.TwodotCore
layers.tensor.TwodotCore(self, data, leg_names, name='B')
Two-dot tensor
\[
B\substack{i_pi_{p+1} \\ \beta_{p-1} \beta_{p+1}}
= \sum_{\beta_p=1}^{M}
W^{[p]}_{\beta_{p-1} i_p \beta_p}
W^{[p+1]}_{\beta_p i_{p+1} \beta_{p+1}}
\]
Methods
as_basis_batch
layers.tensor.TwodotCore.as_basis_batch(name='Phi')
Convert to BasisBatch
as_core
layers.tensor.TwodotCore.as_core(name='W')
Convert to Core
as_core_basis_batch
layers.tensor.TwodotCore.as_core_basis_batch(name='WPhi')
Convert to CoreBasisBatch
as_left_block_batch
layers.tensor.TwodotCore.as_left_block_batch(name='L')
Convert to LeftBlockBatch
as_ndarray
layers.tensor.TwodotCore.as_ndarray()
Convert to jax.Array (Array)
as_right_block_batch
layers.tensor.TwodotCore.as_right_block_batch(name='R')
Convert to RightBlockBatch
as_tensor
layers.tensor.TwodotCore.as_tensor(name='T')
Convert to Tensor
as_twodot_core
layers.tensor.TwodotCore.as_twodot_core(name='B')
Convert to TwodotCore
normalize
layers.tensor.TwodotCore.normalize()
Normalize tensor
Tensor is normalized and return the norm of the tensor.
Returns
Array |
Array |
norm of the tensor before normalization |
scale_to
layers.tensor.TwodotCore.scale_to(scale=None, ord='fro')
Scale maximum abs element of the tensor to the given scale
Parameters
scale |
float | Array |
scale factor. Defaults to jnp.array(1.0). |
None |
ord |
str |
norm type to scale either “fro” or “max”. Defaults to “fro” (Frobenius norm). “fro” : Frobenius norm “max” : maximum absolute value |
'fro' |
Returns
Array |
Array |
multiplication factor to scale the tensor |
svd
layers.tensor.TwodotCore.svd(
rank=None
new_leg_name=None
truncation=1.0
gauge='CR'
)
Singular value decomposition between (0,1) and (2,3) legs
Parameters
rank |
int |
bond dimension (rank). Defaults to None. |
None |
new_leg_name |
str |
new leg name. Defaults to None. |
None |
truncation |
float |
singular value truncation. Defaults to 1.0. |
1.0 |
gauge |
str |
gauge. Defaults to “CR”. |
'CR' |
Examples
>>> import jax.numpy as jnp
>>> from pompon.tt import TensorTrain
>>> tt = TensorTrain.decompose(original_tensor=jnp.ones((4, 4, 4, 4)))
>>> B = tt[0] @ tt[1]
>>> print(B)
TwodotCore(shape=(1, 4, 4, 16), leg_names=('β0', 'i0', 'i1', 'β2'))
>>> print(B.svd(rank=2))
(Core(shape=(1, 4, 2), leg_names=('β0', 'i0', 'β1')), Core(shape=(2, 4, 16), leg_names=('β1', 'i1', 'β2')))
truncate_rank
layers.tensor.TwodotCore.truncate_rank(s, truncation)
Get new bond dimension
Parameters
s |
Array |
singular values in descending order with shape (M,) |
required |
truncation |
float |
singular value truncation |
required |
Returns
int |
int |
new bond dimension (rank) |