deeplabcut.pose_estimation_pytorch.models.necks.utils
Functions:
| Name | Description |
|---|---|
make_sine_position_embedding |
Generate sine position embeddings for a given height, width, and model dimension. |
make_sine_position_embedding
make_sine_position_embedding(
h: int, w: int, d_model: int, temperature: int = 10000, scale: float = 2 * math.pi
) -> torch.Tensor
Generate sine position embeddings for a given height, width, and model dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
int
|
Height of the embedding. |
required |
|
int
|
Width of the embedding. |
required |
|
int
|
Dimension of the model. |
required |
|
int
|
Temperature parameter for position embedding calculation. Defaults to 10000. |
10000
|
|
float
|
Scaling factor for position embedding. Defaults to 2 * math.pi. |
2 * pi
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Sine position embeddings with shape (batch_size, d_model, h * w). |
Example
h, w, d_model = 10, 20, 512 pos_emb = make_sine_position_embedding(h, w, d_model) print(pos_emb.shape) # Output: torch.Size([1, 512, 200])