depth_decay
depth_decay
¶
DepthAwareDecayMask
¶
Bases: Module
Generates attention decay based on depth discontinuities.
Reduces attention across object boundaries by penalizing depth differences between positions.
Initializes depth-aware decay mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number_of_heads
|
int
|
Number of attention heads. |
required |
Source code in src/versatil/models/layers/geometric_attention/depth_decay.py
compute_depth_difference_matrix
staticmethod
¶
Computes pairwise depth differences.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
depth_map
|
Tensor
|
Depth values of shape (B, 1, H, W). |
required |
height
|
int
|
Target height. |
required |
width
|
int
|
Target width. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Depth difference matrix of shape (B, HW, HW). |
Source code in src/versatil/models/layers/geometric_attention/depth_decay.py
compute_1d_depth_difference_matrix
staticmethod
¶
Computes depth differences along one axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
depth_map
|
Tensor
|
Depth values of shape (B, 1, H, W). |
required |
axis
|
str
|
Either 'height' or 'width'. |
required |
height
|
int
|
Target height. |
required |
width
|
int
|
Target width. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Depth differences of shape (B, secondary_length, primary_length, primary_length). |
Source code in src/versatil/models/layers/geometric_attention/depth_decay.py
forward
¶
Generates depth-aware decay mask(s).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
depth_map
|
Tensor
|
Depth map of shape (B, 1, H, W). |
required |
height
|
int
|
Target height. |
required |
width
|
int
|
Target width. |
required |
decay_rates
|
Tensor
|
Per-head decay rates of shape (number_of_heads,). |
required |
decomposition_mode
|
str
|
Whether to generate full or separable masks. |
value
|
Returns:
| Type | Description |
|---|---|
Tensor
|
If FULL: Single mask of shape (B, number_of_heads, HW, HW). |
...
|
If SEPARABLE: Tuple of (height_mask, width_mask). |