Shortcuts

mmedit.models.editors.nafnet.naf_layerNorm2d

Module Contents

Classes

LayerNormFunction

Layer normalization.

LayerNorm2d

Layer normalization module.

class mmedit.models.editors.nafnet.naf_layerNorm2d.LayerNormFunction(*args, **kwargs)[source]

Bases: torch.autograd.Function

Layer normalization.

static forward(ctx, x, weight, bias, eps)[source]

Performs the operation.

This function is to be overridden by all subclasses.

It must accept a context ctx as the first argument, followed by any number of arguments (tensors or other types).

The context can be used to store arbitrary data that can be then retrieved during the backward pass. Tensors should not be stored directly on ctx (though this is not currently enforced for backward compatibility). Instead, tensors should be saved either with ctx.save_for_backward() if they are intended to be used in backward (equivalently, vjp) or ctx.save_for_forward() if they are intended to be used for in jvp.

static backward(ctx, grad_output)[source]

Defines a formula for differentiating the operation with backward mode automatic differentiation (alias to the vjp function).

This function is to be overridden by all subclasses.

It must accept a context ctx as the first argument, followed by as many outputs as the forward() returned (None will be passed in for non tensor outputs of the forward function), and it should return as many tensors, as there were inputs to forward(). Each argument is the gradient w.r.t the given output, and each returned value should be the gradient w.r.t. the corresponding input. If an input is not a Tensor or is a Tensor not requiring grads, you can just pass None as a gradient for that input.

The context can be used to retrieve tensors saved during the forward pass. It also has an attribute ctx.needs_input_grad as a tuple of booleans representing whether each input needs gradient. E.g., backward() will have ctx.needs_input_grad[0] = True if the first input to forward() needs gradient computated w.r.t. the output.

class mmedit.models.editors.nafnet.naf_layerNorm2d.LayerNorm2d(channels, eps=1e-06)[source]

Bases: torch.nn.Module

Layer normalization module.

Note: This is different from the layernorm2d in pytorch.

The layer norm here will handle different channels respectively. For more information, please refer to the issue: https://github.com/megvii-research/NAFNet/issues/35

forward(x)[source]
Read the Docs v: latest
Versions
master
latest
stable
zyh-re-docs
zyh-doc-notfound-extend
zyh-api-rendering
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.