facebookresearch / ConvNeXt

Code release for ConvNeXt model

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

why use the class LayerNorm()? why not using the nn.LayerNorm(dim) in pytorch?

henbucuoshanghai opened this issue · comments

class LayerNorm(nn.Module):
r""" LayerNorm that supports two data formats: channels_last (default) or channels_first.
The ordering of the dimensions in the inputs. channels_last corresponds to inputs with

It's because nn.LayerNorm only supports the case when the channel dimension is at the last. Sometimes our data tensor is NCHW, not NHWC.