Transolver Block
Transolver Block¤
neojax.nn.transolver_block.TransolverBlock
¤
Transolver block.
A pre-norm transformer encoder block whose self-attention is replaced by
PhysicsAttention, i.e.
$$
f' = f + \mathrm{PhysicsAttention}(\mathrm{LN}(f)), \quad
f'' = f' + \mathrm{MLP}(\mathrm{LN}(f')).
$$
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
PRNGKeyArray
|
PRNG key for parameter initialization. |
required |
hidden_channels
|
int
|
Number of input and output channels. |
required |
n_heads
|
int
|
Number of attention heads. Default is 8. |
8
|
slice_num
|
int
|
Number of slices of the |
32
|
mlp_ratio
|
float
|
Ratio of the MLP hidden width to |
4.0
|
dropout
|
float
|
Dropout probability inside the |
0.0
|
activation
|
Callable
|
Activation function of the MLP. Default is |
gelu
|
ndim
|
int | None
|
Number of spatial dimensions for structured grid inputs
(convolutional attention projections) or |
None
|
kernel_size
|
int
|
Kernel size of the convolutional attention projections. Default is 3. |
3
|
temperature_range
|
tuple[float, float] | None
|
Clipping interval of the slice temperature.
See |
(0.1, 5.0)
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Internal Attributes
These fields store the internal layers state (and weights).
- norm_1 (
ChannelLayerNorm): Layer norm before the attention. - attn (
PhysicsAttention): The physics attention. - norm_2 (
ChannelLayerNorm): Layer norm before the MLP. - mlp (
PointwiseMLP): The pointwise MLP.
__call__(x: Inexact[Array, 'c ...'], *, key: PRNGKeyArray | None = None, inference: bool = False) -> Inexact[Array, 'c ...']
¤
Forward pass of the Transolver block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Inexact[Array, 'c ...']
|
Input array shaped (hidden_channels, N) or (hidden_channels, d1, ..., dN). |
required |
key
|
PRNGKeyArray | None
|
PRNG key used for dropout masks. |
None
|
inference
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
Inexact[Array, 'c ...']
|
Output array with the same shape as |