pytorchvideo.models.head¶
-
pytorchvideo.models.head.create_res_basic_head(*, in_features, out_features, pool=<class 'torch.nn.modules.pooling.AvgPool3d'>, output_size=(1, 1, 1), pool_kernel_size=(1, 7, 7), pool_stride=(1, 1, 1), pool_padding=(0, 0, 0), dropout_rate=0.5, activation=None, output_with_global_average=True)[source]¶ Creates ResNet basic head. This layer performs an optional pooling operation followed by an optional dropout, a fully-connected projection, an activation layer and a global spatiotemporal averaging.
Pooling ↓ Dropout ↓ Projection ↓ Activation ↓ AveragingActivation examples include: ReLU, Softmax, Sigmoid, and None. Pool3d examples include: AvgPool3d, MaxPool3d, AdaptiveAvgPool3d, and None.
- Parameters
in_features (int) – input channel size of the resnet head.
out_features (int) – output channel size of the resnet head.
pool (callable) – a callable that constructs resnet head pooling layer, examples include: nn.AvgPool3d, nn.MaxPool3d, nn.AdaptiveAvgPool3d, and None (not applying pooling).
pool_kernel_size (tuple) – pooling kernel size(s) when not using adaptive pooling.
pool_stride (tuple) – pooling stride size(s) when not using adaptive pooling.
pool_padding (tuple) – pooling padding size(s) when not using adaptive pooling.
output_size (tuple) – spatial temporal output size when using adaptive pooling.
activation (callable) – a callable that constructs resnet head activation layer, examples include: nn.ReLU, nn.Softmax, nn.Sigmoid, and None (not applying activation).
dropout_rate (float) – dropout rate.
output_with_global_average (bool) – if True, perform global averaging on temporal and spatial dimensions and reshape output to batch_size x out_features.
- Return type
torch.nn.modules.module.Module
-
class
pytorchvideo.models.head.ResNetBasicHead(pool=None, dropout=None, proj=None, activation=None, output_pool=None)[source]¶ ResNet basic head. This layer performs an optional pooling operation followed by an optional dropout, a fully-connected projection, an optional activation layer and a global spatiotemporal averaging.
Pool3d ↓ Dropout ↓ Projection ↓ Activation ↓ AveragingThe builder can be found in create_res_basic_head.
-
__init__(pool=None, dropout=None, proj=None, activation=None, output_pool=None)[source]¶ - Parameters
pool (torch.nn.modules) – pooling module.
dropout (torch.nn.modules) – dropout module.
proj (torch.nn.modules) – project module.
activation (torch.nn.modules) – activation module.
output_pool (torch.nn.Module) – pooling module for output.
- Return type
-