Shortcuts

mmedit.models.base_archs.linear_module

Module Contents

Classes

LinearModule

A linear block that contains linear/norm/activation layers.

class mmedit.models.base_archs.linear_module.LinearModule(in_features: int, out_features: int, bias: bool = True, act_cfg: Optional[dict] = dict(type='ReLU'), inplace: bool = True, with_spectral_norm: bool = False, order: Tuple[str, str] = ('linear', 'act'))[源代码]

Bases: torch.nn.Module

A linear block that contains linear/norm/activation layers.

For low level vision, we add spectral norm and padding layer.

参数
  • in_features (int) – Same as nn.Linear.

  • out_features (int) – Same as nn.Linear.

  • bias (bool) – Same as nn.Linear. Default: True.

  • act_cfg (dict) – Config dict for activation layer, “relu” by default.

  • inplace (bool) – Whether to use inplace mode for activation. Default: True.

  • with_spectral_norm (bool) – Whether use spectral norm in linear module. Default: False.

  • order (tuple[str]) – The order of linear/activation layers. It is a sequence of “linear”, “norm” and “act”. Examples are (“linear”, “act”) and (“act”, “linear”).

init_weights() None[源代码]

Init weights for the model.

forward(x: torch.Tensor, activate: Optional[bool] = True) torch.Tensor[源代码]

Forward Function.

参数
  • x (torch.Tensor) – Input tensor with shape of \((n, *, c)\). Same as torch.nn.Linear.

  • activate (bool, optional) – Whether to use activation layer. Defaults to True.

返回

Same as torch.nn.Linear.

返回类型

torch.Tensor

Read the Docs v: latest
Versions
master
latest
stable
zyh-doc-notfound-extend
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.