heads
sleap_nn.architectures.heads
¶
Model head definitions for defining model output types.
Classes:
Name | Description |
---|---|
CenteredInstanceConfmapsHead |
Head for specifying centered instance confidence maps. |
CentroidConfmapsHead |
Head for specifying instance centroid confidence maps. |
ClassMapsHead |
Head for specifying class identity maps. |
ClassVectorsHead |
Head for specifying classification heads. |
Head |
Base class for model output heads. |
MultiInstanceConfmapsHead |
Head for specifying multi-instance confidence maps. |
OffsetRefinementHead |
Head for specifying offset refinement maps. |
PartAffinityFieldsHead |
Head for specifying multi-instance part affinity fields. |
SingleInstanceConfmapsHead |
Head for specifying single instance confidence maps. |
CenteredInstanceConfmapsHead
¶
Bases: Head
Head for specifying centered instance confidence maps.
Attributes:
Name | Type | Description |
---|---|---|
part_names |
List of strings specifying the part names associated with channels. |
|
anchor_part |
Name of the part to use as an anchor node. If not specified, the bounding box centroid will be used. |
|
sigma |
Spread of the confidence maps. |
|
output_stride |
Stride of the output head tensor. The input tensor is expected to be at the same stride. |
|
loss_weight |
Weight of the loss term for this head during optimization. |
Methods:
Name | Description |
---|---|
__init__ |
Initialize the object with the specified attributes. |
from_config |
Create this head from a set of configurations. |
Source code in sleap_nn/architectures/heads.py
channels
property
¶
Return the number of channels in the tensor output by this head.
__init__(part_names, anchor_part=None, sigma=5.0, output_stride=1, loss_weight=1.0)
¶
Initialize the object with the specified attributes.
Source code in sleap_nn/architectures/heads.py
from_config(config, part_names=None)
classmethod
¶
Create this head from a set of configurations.
Attributes:
Name | Type | Description |
---|---|---|
config |
A |
|
part_names |
Text name of the body parts (nodes) that the head will be
configured to produce. The number of parts determines the number of
channels in the output. This must be provided if the |
Returns:
Type | Description |
---|---|
CenteredInstanceConfmapsHead
|
The instantiated head with the specified configuration options. |
Source code in sleap_nn/architectures/heads.py
CentroidConfmapsHead
¶
Bases: Head
Head for specifying instance centroid confidence maps.
Attributes:
Name | Type | Description |
---|---|---|
anchor_part |
Name of the part to use as an anchor node. If not specified, the bounding box centroid will be used. |
|
sigma |
Spread of the confidence maps. |
|
output_stride |
Stride of the output head tensor. The input tensor is expected to be at the same stride. |
|
loss_weight |
Weight of the loss term for this head during optimization. |
Methods:
Name | Description |
---|---|
__init__ |
Initialize the object with the specified attributes. |
from_config |
Create this head from a set of configurations. |
Source code in sleap_nn/architectures/heads.py
channels
property
¶
Return the number of channels in the tensor output by this head.
__init__(anchor_part=None, sigma=5.0, output_stride=1, loss_weight=1.0)
¶
Initialize the object with the specified attributes.
Source code in sleap_nn/architectures/heads.py
from_config(config)
classmethod
¶
Create this head from a set of configurations.
Attributes:
Name | Type | Description |
---|---|---|
config |
A |
Returns:
Type | Description |
---|---|
CentroidConfmapsHead
|
The instantiated head with the specified configuration options. |
Source code in sleap_nn/architectures/heads.py
ClassMapsHead
¶
Bases: Head
Head for specifying class identity maps.
Attributes:
Name | Type | Description |
---|---|---|
classes |
List of string names of the classes. |
|
sigma |
Spread of the class maps around each node. |
|
output_stride |
Stride of the output head tensor. The input tensor is expected to be at the same stride. |
|
loss_weight |
Weight of the loss term for this head during optimization. |
Methods:
Name | Description |
---|---|
__init__ |
Initialize the object with the specified attributes. |
from_config |
Create this head from a set of configurations. |
Source code in sleap_nn/architectures/heads.py
activation
property
¶
Return the activation function of the head output layer.
channels
property
¶
Return the number of channels in the tensor output by this head.
__init__(classes, sigma=5.0, output_stride=1, loss_weight=1.0)
¶
Initialize the object with the specified attributes.
Source code in sleap_nn/architectures/heads.py
from_config(config, classes=None)
classmethod
¶
Create this head from a set of configurations.
Attributes:
Name | Type | Description |
---|---|---|
config |
A |
|
classes |
List of string names of the classes that this head will predict.
This must be set if the |
Returns:
Type | Description |
---|---|
ClassMapsHead
|
The instantiated head with the specified configuration options. |
Source code in sleap_nn/architectures/heads.py
ClassVectorsHead
¶
Bases: Head
Head for specifying classification heads.
Attributes:
Name | Type | Description |
---|---|---|
classes |
List of string names of the classes. |
|
num_fc_layers |
Number of fully connected layers after flattening input features. |
|
num_fc_units |
Number of units (dimensions) in fully connected layers prior to classification output. |
|
output_stride |
Stride of the output head tensor. The input tensor is expected to be at the same stride. |
|
loss_weight |
Weight of the loss term for this head during optimization. |
Methods:
Name | Description |
---|---|
__init__ |
Initialize the object with the specified attributes. |
from_config |
Create this head from a set of configurations. |
make_head |
Make head output tensor from input feature tensor. |
Source code in sleap_nn/architectures/heads.py
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
|
activation
property
¶
Return the activation function of the head output layer.
channels
property
¶
Return the number of channels in the tensor output by this head.
loss_function
property
¶
Return the name of the loss function to use for this head.
__init__(classes, num_fc_layers=1, num_fc_units=64, global_pool=True, output_stride=1, loss_weight=1.0)
¶
Initialize the object with the specified attributes.
Source code in sleap_nn/architectures/heads.py
from_config(config, classes=None)
classmethod
¶
Create this head from a set of configurations.
Attributes:
Name | Type | Description |
---|---|---|
config |
A |
|
classes |
List of string names of the classes that this head will predict.
This must be set if the |
Returns:
Type | Description |
---|---|
ClassVectorsHead
|
The instantiated head with the specified configuration options. |
Source code in sleap_nn/architectures/heads.py
make_head(x_in)
¶
Make head output tensor from input feature tensor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x_in
|
int
|
An int for the input shape after applying AdaptiveMaxPool2d on dim=1, assuming inputs of shape (B, C, H, W). |
required |
Returns:
Type | Description |
---|---|
Sequential
|
A |
Source code in sleap_nn/architectures/heads.py
Head
¶
Base class for model output heads.
Attributes:
Name | Type | Description |
---|---|---|
output_stride |
Stride of the output head tensor. The input tensor is expected to be at the same stride. |
|
loss_weight |
Weight of the loss term for this head during optimization. |
Methods:
Name | Description |
---|---|
__init__ |
Initialize the object with the specified attributes. |
make_head |
Make head output tensor from input feature tensor. |
Source code in sleap_nn/architectures/heads.py
activation
property
¶
Return the activation function of the head output layer.
channels
property
¶
Return the number of channels in the tensor output by this head.
loss_function
property
¶
Return the name of the loss function to use for this head.
name
property
¶
Name of the head.
__init__(output_stride=1, loss_weight=1.0)
¶
Initialize the object with the specified attributes.
make_head(x_in)
¶
Make head output tensor from input feature tensor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x_in
|
int
|
An int input for the input channels. |
required |
Returns:
Type | Description |
---|---|
Sequential
|
A |
Source code in sleap_nn/architectures/heads.py
MultiInstanceConfmapsHead
¶
Bases: Head
Head for specifying multi-instance confidence maps.
Attributes:
Name | Type | Description |
---|---|---|
part_names |
List of strings specifying the part names associated with channels. |
|
sigma |
Spread of the confidence maps. |
|
output_stride |
Stride of the output head tensor. The input tensor is expected to be at the same stride. |
|
loss_weight |
Weight of the loss term for this head during optimization. |
Methods:
Name | Description |
---|---|
__init__ |
Initialize the object with the specified attributes. |
from_config |
Create this head from a set of configurations. |
Source code in sleap_nn/architectures/heads.py
channels
property
¶
Return the number of channels in the tensor output by this head.
__init__(part_names, sigma=5.0, output_stride=1, loss_weight=1.0)
¶
Initialize the object with the specified attributes.
Source code in sleap_nn/architectures/heads.py
from_config(config, part_names=None)
classmethod
¶
Create this head from a set of configurations.
Attributes:
Name | Type | Description |
---|---|---|
config |
A |
|
part_names |
Text name of the body parts (nodes) that the head will be
configured to produce. The number of parts determines the number of
channels in the output. This must be provided if the |
Returns:
Type | Description |
---|---|
MultiInstanceConfmapsHead
|
The instantiated head with the specified configuration options. |
Source code in sleap_nn/architectures/heads.py
OffsetRefinementHead
¶
Bases: Head
Head for specifying offset refinement maps.
Attributes:
Name | Type | Description |
---|---|---|
part_names |
List of strings specifying the part names associated with channels. |
|
sigma_threshold |
Threshold of confidence map values to use for defining the boundary of the offset maps. |
|
output_stride |
Stride of the output head tensor. The input tensor is expected to be at the same stride. |
|
loss_weight |
Weight of the loss term for this head during optimization. |
Methods:
Name | Description |
---|---|
__init__ |
Initialize the object with the specified attributes. |
from_config |
Create this head from a set of configurations. |
Source code in sleap_nn/architectures/heads.py
channels
property
¶
Return the number of channels in the tensor output by this head.
__init__(part_names, sigma_threshold=0.2, output_stride=1, loss_weight=1.0)
¶
Initialize the object with the specified attributes.
Source code in sleap_nn/architectures/heads.py
from_config(config, part_names=None, sigma_threshold=0.2, loss_weight=1.0)
classmethod
¶
Create this head from a set of configurations.
Attributes:
Name | Type | Description |
---|---|---|
config |
A |
|
part_names |
Text name of the body parts (nodes) that the head will be
configured to produce. The number of parts determines the number of
channels in the output. This must be provided if the |
|
sigma_threshold |
Minimum confidence map value below which offsets will be replaced with zeros. |
|
loss_weight |
Weight of the loss associated with this head. |
Returns:
Type | Description |
---|---|
OffsetRefinementHead
|
The instantiated head with the specified configuration options. |
Source code in sleap_nn/architectures/heads.py
PartAffinityFieldsHead
¶
Bases: Head
Head for specifying multi-instance part affinity fields.
Attributes:
Name | Type | Description |
---|---|---|
edges |
List of tuples of |
|
sigma |
Spread of the part affinity fields. |
|
output_stride |
Stride of the output head tensor. The input tensor is expected to be at the same stride. |
|
loss_weight |
Weight of the loss term for this head during optimization. |
Methods:
Name | Description |
---|---|
__init__ |
Initialize the object with the specified attributes. |
from_config |
Create this head from a set of configurations. |
Source code in sleap_nn/architectures/heads.py
channels
property
¶
Return the number of channels in the tensor output by this head.
__init__(edges, sigma=5.0, output_stride=1, loss_weight=1.0)
¶
Initialize the object with the specified attributes.
Source code in sleap_nn/architectures/heads.py
from_config(config, edges=None)
classmethod
¶
Create this head from a set of configurations.
Attributes:
Name | Type | Description |
---|---|---|
config |
A |
|
edges |
List of 2-tuples of the form |
Returns:
Type | Description |
---|---|
PartAffinityFieldsHead
|
The instantiated head with the specified configuration options. |
Source code in sleap_nn/architectures/heads.py
SingleInstanceConfmapsHead
¶
Bases: Head
Head for specifying single instance confidence maps.
Attributes:
Name | Type | Description |
---|---|---|
part_names |
List of strings specifying the part names associated with channels. |
|
sigma |
Spread of the confidence maps. |
|
output_stride |
Stride of the output head tensor. The input tensor is expected to be at the same stride. |
|
loss_weight |
Weight of the loss term for this head during optimization. |
Methods:
Name | Description |
---|---|
__init__ |
Initialize the object with the specified attributes. |
from_config |
Create this head from a set of configurations. |
Source code in sleap_nn/architectures/heads.py
channels
property
¶
Return the number of channels in the tensor output by this head.
__init__(part_names, sigma=5.0, output_stride=1, loss_weight=1.0)
¶
Initialize the object with the specified attributes.
Source code in sleap_nn/architectures/heads.py
from_config(config, part_names=None)
classmethod
¶
Create this head from a set of configurations.
Attributes:
Name | Type | Description |
---|---|---|
config |
A |
|
part_names |
Text name of the body parts (nodes) that the head will be
configured to produce. The number of parts determines the number of
channels in the output. This must be provided if the |
Returns:
Type | Description |
---|---|
SingleInstanceConfmapsHead
|
The instantiated head with the specified configuration options. |