Tucker Tensor
Tucker Tensor¤
Represents the weights in a Tucker decomposition format, factorized into a core tensor and mode-specific factor matrices.
neojax.tensor.tucker_tensor.TuckerTensor
¤
Tucker-factorized spectral tensor.
Decomposes the spectral weight tensor \(W\) into a core tensor \(G\) and factor matrices \(U^{(j)}\) for each dimension.
For the standard case (separable=False),
the weight tensor \(W \in \mathbb{C}^{C_{out} \times C_{in} \times m_1 \times \dots \times m_d}\) is reconstructed as:
For the separable case (separable=True),
the weight tensor \(W \in \mathbb{C}^{C \times m_1 \times \dots \times m_d}\) is reconstructed as:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
PRNGKeyArray
|
PRNG key for weight initialization. |
required |
in_channels
|
int
|
Number of input channels. |
required |
out_channels
|
int
|
Number of output channels. |
required |
modes
|
Sequence[int]
|
Number of Fourier modes to retain across each spatial dim. |
required |
ranks
|
int | Sequence[int]
|
Number of ranks to contract the spectral tensors to.
If |
required |
init_std
|
Union[float, Literal['auto']]
|
Standard deviation to use for weight initialization, by default 'auto'. If 'auto', uses (2 / (in_channels + out_channels)) ** 0.5. |
'auto'
|
separable
|
bool
|
Whether to use separable implementation of contraction. If True, contracts factors of factorized tensor weight individually. Default is False. |
False
|
Internal Attributes
- core_tensors (
tuple[Complex[Array, ...], ...]): Learnable complex core weight tensors. - factor_matrices (
tuple[Complex[Array, ...], ...]): Learnable factor matrices for each dimension. - einsum_str (
str): Contraction string passed directly tojnp.einsum. - to_dense_einsum_str (
str): Contraction string passed tojnp.einsuminto_dense. - ndim (
int): Total dimensions of the tensor structure (channels + spatial). - separable (bool): Whether to use separable implementation of contraction.
to_dense() -> Complex[Array, 'n_corners ...']
¤
Reconstruct factorized tensors into single dense tensor.
Useful, e.g. if the reconstructed flag is True.
Returns:
| Type | Description |
|---|---|
Complex[Array, 'n_corners ...']
|
Reconstructed dense tensors stacked along first axis. |
__call__(corner_idx: int, x_ft_slice: Complex[Array, 'in_c ...']) -> Complex[Array, ...]
¤
Performs tucker tensor contraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
corner_idx
|
int
|
Corner index of the n-dim FFT hypercube. |
required |
x_ft_slice
|
Complex[Array, 'in_c ...']
|
Mode slice of fourier transformed input. |
required |
Returns:
| Type | Description |
|---|---|
Complex[Array, ...]
|
Tensor contraction of respective weight and input. |