class_docstr: This head defines a 2d average pooling layer
  (:class:`torch.nn.AdaptiveAvgPool2d`) followed by a fully connected
  layer (:class:`torch.nn.Linear`).
docstr: Constructor for FullyConnectedHead
  
  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. If None, then the fully
          connected layer is not applied.
      in_plane: Input size for the fully connected layer.
      conv_planes: If specified, applies a 1x1 convolutional layer to the input
          before passing it to the average pooling layer. The convolution is also
          followed by a BatchNorm and an activation.
      activation: The activation to be applied after the convolutional layer.
          Unused if `conv_planes` is not specified.
      zero_init_bias: Zero initialize the bias
      normalize_inputs: If specified, normalize the inputs after performing
          average pooling using the specified method. Supports "l2" normalization.
docstr_tok: ["Constructor","for","FullyConnectedHead","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",".","If","None",",","then","the","fully","connected","layer","is","not","applied",".","in_plane",":","Input","size","for","the","fully","connected","layer",".","conv_planes",":","If","specified",",","applies","a","1x1","convolutional","layer","to","the","input","before","passing","it","to","the","average","pooling","layer",".","The","convolution","is","also","followed","by","a","BatchNorm","and","an","activation",".","activation",":","The","activation","to","be","applied","after","the","convolutional","layer",".","Unused","if","`","conv_planes","`","is","not","specified",".","zero_init_bias",":","Zero","initialize","the","bias","normalize_inputs",":","If","specified",",","normalize","the","inputs","after","performing","average","pooling","using","the","specified","method",".","Supports","``","l2","''","normalization","."]
code: def __init__(
      self,
      unique_id: str,
      num_classes: Optional[int],
      in_plane: int,
      conv_planes: Optional[int] = None,
      activation: Optional[nn.Module] = None,
      zero_init_bias: bool = False,
      normalize_inputs: Optional[str] = None,
  ):
      """Constructor for FullyConnectedHead
  
      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. If None, then the fully
              connected layer is not applied.
          in_plane: Input size for the fully connected layer.
          conv_planes: If specified, applies a 1x1 convolutional layer to the input
              before passing it to the average pooling layer. The convolution is also
              followed by a BatchNorm and an activation.
          activation: The activation to be applied after the convolutional layer.
              Unused if `conv_planes` is not specified.
          zero_init_bias: Zero initialize the bias
          normalize_inputs: If specified, normalize the inputs after performing
              average pooling using the specified method. Supports "l2" normalization.
      """
      super().__init__(unique_id, num_classes)
      assert num_classes is None or is_pos_int(num_classes)
      assert is_pos_int(in_plane)
      if conv_planes is not None and activation is None:
          raise TypeError(
              "activation cannot be None if conv_planes is specified"
          )
      if (
          normalize_inputs is not None
          and normalize_inputs != NORMALIZE_L2
      ):
          raise ValueError(
              f"Unsupported value for normalize_inputs: {normalize_inputs}"
          )
      self.conv = (
          nn.Conv2d(in_plane, conv_planes, kernel_size=1, bias=False)
          if conv_planes
          else None
      )
      self.bn = nn.BatchNorm2d(conv_planes) if conv_planes else None
      self.activation = activation
      self.avgpool = nn.AdaptiveAvgPool2d((1, 1))
      self.fc = (
          None
          if num_classes is None
          else nn.Linear(
              in_plane if conv_planes is None else conv_planes,
              num_classes,
          )
      )
      self.normalize_inputs = normalize_inputs
  
      if zero_init_bias:
          self.fc.bias.data.zero_()
  
file_path: ClassyVision/classy_vision/heads/fully_connected_head.py
imports: from typing import Any, Dict, Optional
  import torch.nn
  from classy_vision.generic.util import get_torch_version, is_pos_int
  from classy_vision.heads import ClassyHead, register_head
label_desc: Use image node_id 1 to create a new FullyConnectedHead object from inherited base classes: ClassyHead with example: obj = FullyConnectedHead(unique_id, num_classes, in_plane, conv_planes, activation, zero_init_bias, normalize_inputs)