class_docstr: This head defines a 3d average pooling layer (:class:`torch.nn.AvgPool3d` or
  :class:`torch.nn.AdaptiveAvgPool3d` if pool_size is None) followed by a fully
  convolutional linear layer. This layer performs a fully-connected projection
  during training, when the input size is 1x1x1.
  It performs a convolutional projection during testing when the input size
  is larger than 1x1x1.
class_docstr_tok: ["This","head","defines","a","3d","average","pooling","layer","(",":","class",":","`","torch.nn.AvgPool3d","`","or",":","class",":","`","torch.nn.AdaptiveAvgPool3d","`","if","pool_size","is","None",")","followed","by","a","fully","convolutional","linear","layer",".","This","layer","performs","a","fully-connected","projection","during","training",",","when","the","input","size","is","1x1x1",".","It","performs","a","convolutional","projection","during","testing","when","the","input","size","is","larger","than","1x1x1","."]
docstr: Constructor for FullyConvolutionalLinearHead.
  
  Args:
      unique_id: A unique identifier for the head. Multiple instances of
          the same head might be attached to a model, and unique_id is used
          to refer to them.
      num_classes: Number of classes for the head.
      in_plane: Input size for the fully connected layer.
      pool_size: Optional kernel size for the 3d pooling layer. If None, use
          :class:`torch.nn.AdaptiveAvgPool3d` with output size (1, 1, 1).
      activation_func: activation function to use. 'softmax': applies
          softmax on the output. 'sigmoid': applies sigmoid on the output.
      use_dropout: Whether to apply dropout after the pooling layer.
      dropout_ratio: dropout ratio.
docstr_tok: ["Constructor","for","FullyConvolutionalLinearHead",".","Args",":","unique_id",":","A","unique","identifier","for","the","head",".","Multiple","instances","of","the","same","head","might","be","attached","to","a","model",",","and","unique_id","is","used","to","refer","to","them",".","num_classes",":","Number","of","classes","for","the","head",".","in_plane",":","Input","size","for","the","fully","connected","layer",".","pool_size",":","Optional","kernel","size","for","the","3d","pooling","layer",".","If","None",",","use",":","class",":","`","torch.nn.AdaptiveAvgPool3d","`","with","output","size","(","1",",","1",",","1",")",".","activation_func",":","activation","function","to","use",".","'softmax","'",":","applies","softmax","on","the","output",".","'sigmoid","'",":","applies","sigmoid","on","the","output",".","use_dropout",":","Whether","to","apply","dropout","after","the","pooling","layer",".","dropout_ratio",":","dropout","ratio","."]
code: def __init__(
      self,
      unique_id: str,
      num_classes: int,
      in_plane: int,
      pool_size: Optional[List[int]],
      activation_func: str,
      use_dropout: Optional[bool] = None,
      dropout_ratio: float = 0.5,
  ):
      """
      Constructor for FullyConvolutionalLinearHead.
  
      Args:
          unique_id: A unique identifier for the head. Multiple instances of
              the same head might be attached to a model, and unique_id is used
              to refer to them.
          num_classes: Number of classes for the head.
          in_plane: Input size for the fully connected layer.
          pool_size: Optional kernel size for the 3d pooling layer. If None, use
              :class:`torch.nn.AdaptiveAvgPool3d` with output size (1, 1, 1).
          activation_func: activation function to use. 'softmax': applies
              softmax on the output. 'sigmoid': applies sigmoid on the output.
          use_dropout: Whether to apply dropout after the pooling layer.
          dropout_ratio: dropout ratio.
      """
      super().__init__(unique_id, num_classes)
      if pool_size is not None:
          self.final_avgpool = nn.AvgPool3d(pool_size, stride=1)
      else:
          self.final_avgpool = nn.AdaptiveAvgPool3d((1, 1, 1))
      if use_dropout:
          self.dropout = nn.Dropout(p=dropout_ratio)
      # we separate average pooling from the fully-convolutional linear projection
      # because for multi-path models such as SlowFast model, the input can be
      # more than 1 tesnor. In such case, we can define a new head to combine multiple
      # tensors via concat or addition, do average pooling, but still reuse
      # FullyConvolutionalLinear inside of it.
      self.head_fcl = FullyConvolutionalLinear(
          in_plane, num_classes, act_func=activation_func
      )
  
file_path: ClassyVision/classy_vision/heads/fully_convolutional_linear_head.py
imports: from collections.abc import Sequence
  from typing import Any, Dict, List, Optional
  import torch.nn
  from classy_vision.generic.util import is_pos_int
  from classy_vision.heads import ClassyHead, register_head
label_desc: Use image node_id 1 to create a new FullyConvolutionalLinearHead object from inherited base classes: ClassyHead with example: obj = FullyConvolutionalLinearHead(unique_id, num_classes, in_plane, pool_size, activation_func, use_dropout, dropout_ratio)