Shortcuts

LayerScale

class mmcv.cnn.LayerScale(dim: int, inplace: bool = False, data_format: str = 'channels_last', scale: float = 1e-05)[source]

LayerScale layer.

Parameters:
  • dim (int) – Dimension of input features.

  • inplace (bool) – Whether performs operation in-place. Default: False.

  • data_format (str) – The input data format, could be ‘channels_last’ or ‘channels_first’, representing (B, C, H, W) and (B, N, C) format data respectively. Default: ‘channels_last’.

  • scale (float) – Initial value of scale factor. Default: 1.0

forward(x) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.