class_docstr: Base class for different image classification models
class_docstr_tok: ["Base","class","for","different","image","classification","models"]
docstr: This function updates the classification layer in a model. Useful for fine-tuning purposes.
docstr_tok: ["This","function","updates","the","classification","layer","in","a","model",".","Useful","for","fine-tuning","purposes","."]
code: def update_classifier(
      self, opts: argparse.Namespace, n_classes: int
  ) -> None:
      """This function updates the classification layer in a model. Useful for fine-tuning purposes."""
      logger.warning(
          "We encourage to use model scopes (`--model.resume-exclude-scopes`, `--model.ignore-missing-scopes`, "
          "and `--model.rename-scopes-map`) for updating classifier for fine-tuning tasks. We will be "
          "deprecating this function in future."
      )
  
      linear_init_type = getattr(
          opts, "model.layer.linear_init", "normal"
      )
      if isinstance(self.classifier, nn.Sequential):
          in_features = self.classifier[-1].in_features
          layer = LinearLayer(
              in_features=in_features, out_features=n_classes, bias=True
          )
          initialize_fc_layer(layer, init_method=linear_init_type)
          self.classifier[-1] = layer
      else:
          in_features = self.classifier.in_features
          layer = LinearLayer(
              in_features=in_features, out_features=n_classes, bias=True
          )
          initialize_fc_layer(layer, init_method=linear_init_type)
  
          # re-init head
          head_init_scale = 0.001
          layer.weight.data.mul_(head_init_scale)
          layer.bias.data.mul_(head_init_scale)
  
          self.classifier = layer
  
imports: import argparse
  from typing import Any, Dict, List, Mapping, Optional, Tuple
  import torch
  from torch import Tensor, nn
  from torch.utils.checkpoint import checkpoint
  from common import is_test_env
  from cvnets.layers import LinearLayer
  from cvnets.misc.init_utils import initialize_fc_layer
  from cvnets.models import MODEL_REGISTRY, BaseAnyNNModel
  from cvnets.neural_augmentor import build_neural_augmentor
  from utils import logger
label_desc: Use image node_id 4 for calling the BaseImageEncoder obj's underlying member method code with example usage: obj.update_classifier(opts, n_classes) without return types