Modules
We offer torch modules as well for easy integration into your neural network:
natten.NeighborhoodAttention1D
1-D Neighborhood Attention torch module.
Includes QKV and output linear projections.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dim
|
int
|
Number of input latent dimensions (channels). Note This is not |
required |
num_heads
|
int
|
Number of attention heads. |
required |
kernel_size
|
Tuple[int] | int
|
Neighborhood window (kernel) size. Note
|
required |
stride
|
Tuple[int] | int
|
Sliding window step size. Defaults to Note
|
1
|
dilation
|
Tuple[int] | int
|
Dilation step size. Defaults to Note The product of |
1
|
is_causal
|
Tuple[bool] | bool
|
Toggle causal masking. Defaults to |
False
|
qkv_bias
|
bool
|
Enable bias in the QKV linear projection. |
True
|
qk_scale
|
Optional[float]
|
Attention scale. Defaults to |
None
|
proj_drop
|
float
|
Dropout score for projection layer. Defaults is |
0.0
|
natten.NeighborhoodAttention2D
2-D Neighborhood Attention torch module.
Includes QKV and output linear projections.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dim
|
int
|
Number of input latent dimensions (channels). Note This is not |
required |
num_heads
|
int
|
Number of attention heads. |
required |
kernel_size
|
Tuple[int, int] | int
|
Neighborhood window (kernel) size/shape. If an
integer, it will be repeated for all 2 dimensions. For example Note
|
required |
stride
|
Tuple[int, int] | int
|
Sliding window step size/shape. Defaults to Note
|
1
|
dilation
|
Tuple[int, int] | int
|
Dilation step size/shape. Defaults to Note The product of |
1
|
is_causal
|
Tuple[bool, bool] | bool
|
Toggle causal masking. Defaults to |
False
|
qkv_bias
|
bool
|
Enable bias in the QKV linear projection. |
True
|
qk_scale
|
Optional[float]
|
Attention scale. Defaults to |
None
|
proj_drop
|
float
|
Dropout score for projection layer. Defaults is |
0.0
|
natten.NeighborhoodAttention3D
3-D Neighborhood Attention torch module.
Includes QKV and output linear projections.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dim
|
int
|
Number of input latent dimensions (channels). Note This is not |
required |
num_heads
|
int
|
Number of attention heads. |
required |
kernel_size
|
Tuple[int, int, int] | int
|
Neighborhood window (kernel) size/shape. If an
integer, it will be repeated for all 3 dimensions. For example Note
|
required |
stride
|
Tuple[int, int, int] | int
|
Sliding window step size/shape. Defaults to Note
|
1
|
dilation
|
Tuple[int, int, int] | int
|
Dilation step size/shape. Defaults to Note The product of |
1
|
is_causal
|
Tuple[bool, bool, bool] | bool
|
Toggle causal masking. Defaults to |
False
|
qkv_bias
|
bool
|
Enable bias in the QKV linear projection. |
True
|
qk_scale
|
Optional[float]
|
Attention scale. Defaults to |
None
|
proj_drop
|
float
|
Dropout score for projection layer. Defaults is |
0.0
|