class_docstr: This module can be used to attach combination of {Linear, BatchNorm, Relu, Dropout}
  layers and they are fully configurable from the config file. The module also supports
  stacking multiple MLPs.
  
  Examples:
      Linear
      Linear -> BN
      Linear -> ReLU
      Linear -> Dropout
      Linear -> BN -> ReLU -> Dropout
      Linear -> ReLU -> Dropout
      Linear -> ReLU -> Linear -> ReLU -> ...
      Linear -> Linear -> ...
      ...
  
  Accepts a 2D input tensor. Also accepts 4D input tensor of shape `N x C x 1 x 1`.
class_docstr_tok: ["This","module","can","be","used","to","attach","combination","of","{","Linear",",","BatchNorm",",","Relu",",","Dropout","}","layers","and","they","are","fully","configurable","from","the","config","file",".","The","module","also","supports","stacking","multiple","MLPs",".","Examples",":","Linear","Linear","-",">","BN","Linear","-",">","ReLU","Linear","-",">","Dropout","Linear","-",">","BN","-",">","ReLU","-",">","Dropout","Linear","-",">","ReLU","-",">","Dropout","Linear","-",">","ReLU","-",">","Linear","-",">","ReLU","-",">","...","Linear","-",">","Linear","-",">","...","...","Accepts","a","2D","input","tensor",".","Also","accepts","4D","input","tensor","of","shape","`","N","x","C","x","1","x","1","`","."]
docstr: Args:
      model_config (AttrDict): dictionary config.MODEL in the config file
      use_bn (bool): whether to attach BatchNorm after Linear layer
      use_relu (bool): whether to attach ReLU after (Linear (-> BN optional))
      use_dropout (bool): whether to attach Dropout after
                          (Linear (-> BN -> relu optional))
      use_bias (bool): whether the Linear layer should have bias or not
      dims (int): dimensions of the linear layer. Example [8192, 1000] which
                  attaches `nn.Linear(8192, 1000, bias=True)`
      skip_last_layer_relu_bn (bool): If the MLP has many layers, we check
          if after the last MLP layer, we should add BN / ReLU or not. By
          default, skip it. If user specifies to not skip, then BN will be
          added if use_bn=True, ReLU will be added if use_relu=True
docstr_tok: ["Args",":","model_config","(","AttrDict",")",":","dictionary","config.MODEL","in","the","config","file","use_bn","(","bool",")",":","whether","to","attach","BatchNorm","after","Linear","layer","use_relu","(","bool",")",":","whether","to","attach","ReLU","after","(","Linear","(","-",">","BN","optional",")",")","use_dropout","(","bool",")",":","whether","to","attach","Dropout","after","(","Linear","(","-",">","BN","-",">","relu","optional",")",")","use_bias","(","bool",")",":","whether","the","Linear","layer","should","have","bias","or","not","dims","(","int",")",":","dimensions","of","the","linear","layer",".","Example","[","8192",",","1000","]","which","attaches","`","nn.Linear","(","8192",",","1000",",","bias=True",")","`","skip_last_layer_relu_bn","(","bool",")",":","If","the","MLP","has","many","layers",",","we","check","if","after","the","last","MLP","layer",",","we","should","add","BN","\/","ReLU","or","not",".","By","default",",","skip","it",".","If","user","specifies","to","not","skip",",","then","BN","will","be","added","if","use_bn=True",",","ReLU","will","be","added","if","use_relu=True"]
code: def __init__(
      self,
      model_config: AttrDict,
      dims: List[int],
      use_bn: bool = False,
      use_relu: bool = False,
      use_dropout: bool = False,
      use_bias: bool = True,
      skip_last_layer_relu_bn: bool = True,
  ):
      """
      Args:
          model_config (AttrDict): dictionary config.MODEL in the config file
          use_bn (bool): whether to attach BatchNorm after Linear layer
          use_relu (bool): whether to attach ReLU after (Linear (-> BN optional))
          use_dropout (bool): whether to attach Dropout after
                              (Linear (-> BN -> relu optional))
          use_bias (bool): whether the Linear layer should have bias or not
          dims (int): dimensions of the linear layer. Example [8192, 1000] which
                      attaches `nn.Linear(8192, 1000, bias=True)`
          skip_last_layer_relu_bn (bool): If the MLP has many layers, we check
              if after the last MLP layer, we should add BN / ReLU or not. By
              default, skip it. If user specifies to not skip, then BN will be
              added if use_bn=True, ReLU will be added if use_relu=True
      """
      super().__init__()
      layers = self.create_layers(
          model_config,
          dims,
          use_bn,
          use_relu,
          use_dropout,
          use_bias,
          skip_last_layer_relu_bn,
      )
      self.clf = nn.Sequential(*layers)
      # we use the default normal or uniform initialization for the layers
      # and allow users to scale the initialization.
      self.scale_weights(model_config)
  
file_path: vissl/vissl/models/heads/mlp.py
imports: from typing import List
  import torch
  import torch.nn
  from vissl.config import AttrDict
  from vissl.models.heads import register_model_head
  from vissl.utils.fsdp_utils import fsdp_auto_wrap_bn, fsdp_wrapper
label_desc: Use image node_id 1 to create a new MLP object from inherited base classes: nn with example: obj = MLP(model_config, dims, use_bn, use_relu, use_dropout, use_bias, skip_last_layer_relu_bn)