class_docstr: Linear head for re-identification.
  
  Args:
      num_fcs (int): Number of fcs.
      in_channels (int): Number of channels in the input.
      fc_channels (int): Number of channels in the fcs.
      out_channels (int): Number of channels in the output.
      norm_cfg (dict, optional): Configuration of normlization method
          after fc. Defaults to None.
      act_cfg (dict, optional): Configuration of activation method after fc.
          Defaults to None.
      num_classes (int, optional): Number of the identities. Default to None.
      loss_cls (dict, optional): Cross entropy loss to train the ReID module.
          Defaults to None.
      loss_triplet (dict, optional): Triplet loss to train the ReID module.
          Defaults to None.
      topk (int | Tuple[int]): Top-k accuracy. Defaults to ``(1, )``.
      init_cfg (dict or list[dict], optional): Initialization config dict.
          Defaults to dict(type='Normal',layer='Linear', mean=0, std=0.01,
          bias=0).
class_docstr_tok: ["Linear","head","for","re-identification",".","Args",":","num_fcs","(","int",")",":","Number","of","fcs",".","in_channels","(","int",")",":","Number","of","channels","in","the","input",".","fc_channels","(","int",")",":","Number","of","channels","in","the","fcs",".","out_channels","(","int",")",":","Number","of","channels","in","the","output",".","norm_cfg","(","dict",",","optional",")",":","Configuration","of","normlization","method","after","fc",".","Defaults","to","None",".","act_cfg","(","dict",",","optional",")",":","Configuration","of","activation","method","after","fc",".","Defaults","to","None",".","num_classes","(","int",",","optional",")",":","Number","of","the","identities",".","Default","to","None",".","loss_cls","(","dict",",","optional",")",":","Cross","entropy","loss","to","train","the","ReID","module",".","Defaults","to","None",".","loss_triplet","(","dict",",","optional",")",":","Triplet","loss","to","train","the","ReID","module",".","Defaults","to","None",".","topk","(","int","|","Tuple","[","int","]",")",":","Top-k","accuracy",".","Defaults","to","``","(","1",",",")","``",".","init_cfg","(","dict","or","list","[","dict","]",",","optional",")",":","Initialization","config","dict",".","Defaults","to","dict","(","type='Normal","'",",","layer='Linear","'",",","mean=0",",","std=0.01",",","bias=0",")","."]
code: def __init__(
      self,
      num_fcs: int,
      in_channels: int,
      fc_channels: int,
      out_channels: int,
      norm_cfg: Optional[dict] = None,
      act_cfg: Optional[dict] = None,
      num_classes: Optional[int] = None,
      loss_cls: Optional[dict] = None,
      loss_triplet: Optional[dict] = None,
      topk: Union[int, Tuple[int]] = (1,),
      init_cfg: Union[dict, List[dict]] = dict(
          type="Normal", layer="Linear", mean=0, std=0.01, bias=0
      ),
  ):
      if mmpretrain is None:
          raise RuntimeError(
              'Please run "pip install openmim" and '
              'run "mim install mmpretrain" to '
              "install mmpretrain first."
          )
      super(LinearReIDHead, self).__init__(init_cfg=init_cfg)
  
      assert isinstance(topk, (int, tuple))
      if isinstance(topk, int):
          topk = (topk,)
      for _topk in topk:
          assert _topk > 0, "Top-k should be larger than 0"
      self.topk = topk
  
      if loss_cls is None:
          if isinstance(num_classes, int):
              warnings.warn(
                  "Since cross entropy is not set, "
                  "the num_classes will be ignored."
              )
          if loss_triplet is None:
              raise ValueError(
                  "Please choose at least one loss in "
                  "triplet loss and cross entropy loss."
              )
      elif not isinstance(num_classes, int):
          raise TypeError(
              "The num_classes must be a current number, "
              "if there is cross entropy loss."
          )
      self.loss_cls = MODELS.build(loss_cls) if loss_cls else None
      self.loss_triplet = (
          MODELS.build(loss_triplet) if loss_triplet else None
      )
  
      self.num_fcs = num_fcs
      self.in_channels = in_channels
      self.fc_channels = fc_channels
      self.out_channels = out_channels
      self.norm_cfg = norm_cfg
      self.act_cfg = act_cfg
      self.num_classes = num_classes
  
      self._init_layers()
  
file_path: mmdetection/mmdet/models/reid/linear_reid_head.py
imports: import warnings
  from typing import List, Optional, Tuple, Union
  import torch
  import torch.nn
  from mmengine.model import BaseModule
  from mmdet.registry import MODELS
  from mmdet.structures import ReIDDataSample
  from .fc_module import FcModule
label_desc: Use image node_id 1 to create a new LinearReIDHead object from inherited base classes: BaseModule with example: obj = LinearReIDHead(num_fcs, in_channels, fc_channels, out_channels, norm_cfg, act_cfg, num_classes, loss_cls, loss_triplet, topk, init_cfg)