LayerNorm Axis: Same shape can match different questions

Enter shape [B], T, D] often indicates batches, locations and characteristics.

• Step by stepCollate in 2 self-measured2 First-hand sources
Start Body
Learning objectives and first steps2 objectives 2 first fixes

Try to do it after reading

  • Determine the dimensions of LayerNorm return
  • Manual press token Difference to whole-series statistics

Suggested first

  • Vector and Matrix Operations
  • Counts and chain rules

Normalization is not just a dimension number

Enter shape [B], T, D] often indicates batches, locations and characteristics. The language model often makes LayerNorm in the last D dimension of each location, allowing each token to use its own characterization independently. But if [T, D] were to be regularized together, it would be cross-positioned within the same sequence and the meaning of the model has changed. Both forms can run and cannot be judged correctly simply by the output shape.

Take a series, two locations, two features per location, with a value [[1,3], [5,7]]. Press each location. D The averages of 2 and 6 lines, each standard difference of 1 line, were calculated in terms of both rows, and the last two rows were changed to [−1,1]. If the average value is 4 and the difference is 5 over four digits, the output is approximately [−1.341641, -0.447214, 0.4477214, 1.341641].

The latter result preserves the difference between the two positions relative to the average of the whole paragraph, but relies on the content of the whole paragraph; Statistics also change when the sequence length changes or joins padding. This cross-prospecting of future locations is particularly relevant for systems requiring location-by-position processing, and the visible range cannot be judged to be correct because the name of the module is still LayerNorm.

shape of the emulation parameter also changes in the scope of the reclassification. (a) When only uniform D, each feature has a scaling and scaling; If the range contains T, the parameters may also be tied to the location size to the detriment of any length input. Actualizes the definition of API, which is to check the weight of the parameter and weight load on the migration instead of simply copying the module name.

LayerNorm does not normally run average value across batch in BN, so the same statistical way is entered in training and reasoning. However, the Dropout, other status and dtype before and after the module may still cause differences; “Regularization does not automatically identify missing features and should be clearly stated in the data agreement.

This example can be reviewed directly by using the four-digit mean variance, and the formula ignores the difference between the pebble and the emulator to highlight the axis.

The output shape is all [1,2,2], why is the result still different?

(a) The axle of attribution changes the mean value and the variance; The output maintains the original shape does not indicate that the same set of statistics is used for each count.

Could the reclassification of padding to zero and cross T affect its validity?

Yes, if these zero-sum statistics are involved, the mean-to-form ratio changes. The mission-specific axle and masking strategy is required.

LayerNorm Simulation parameters shape Usually corresponds to normalized_shape And... GroupNorm Usually, you set the simulation parameters by channel. Even if some subgroups count the same, the way in which they can be scaled and moved peacefully may vary, and the two floors of full parity cannot be determined on the basis of a single mean difference.

Sources and reconciliations

Definitions, methods and interfaces are available.

  1. Layer Normalization
  2. D2L — Batch Normalization

Figures and calculations are reorganized according to this chapter. Mathematical measurements, framework operations and real business effects are described separately in the body of the text.

← Back to the knowledge directory
Ask Max Ask about this site
Ask Max ↗

Opening the assistant…

Paper figure

Photo comments

LEAVE A NOTE

About this photograph

Connecting to the discussion board…

    Comments become public after moderation. You can delete your own comments from this browser.
    No email is required. Clearing cookies prevents this browser from claiming earlier comments.

    MAX WANG / INDEX

    Find something

    Enter a keyword, or explore the directory below.