Class LayerNorm.Builder

java.lang.Object
ai.djl.nn.norm.LayerNorm.Builder
Enclosing class:
LayerNorm

public static class LayerNorm.Builder extends Object
The Builder to construct a LayerNorm.
  • Constructor Details

    • Builder

      protected Builder()
  • Method Details

    • axis

      public LayerNorm.Builder axis(int... axis)
      List the axis over which the mean and variance will be calculated (alternative to normalizedShape).
      Parameters:
      axis - input axis over which the mean and variance will be calculated (if null all existing dimensions)
      Returns:
      this Builder
    • optCenter

      public LayerNorm.Builder optCenter(boolean val)
      If True, add offset of `beta` to normalized tensor. Defaults to True.
      Parameters:
      val - True or False on whether to add and train offset value
      Returns:
      this Builder
    • optScale

      public LayerNorm.Builder optScale(boolean val)
      If True, multiply result by `gamma`. Defaults to True;
      Parameters:
      val - True or False on whether to add and train scale value
      Returns:
      this Builder
    • optEpsilon

      public LayerNorm.Builder optEpsilon(float val)
      Sets the epsilon value to prevent division by 0.
      Parameters:
      val - the epsilon value
      Returns:
      this Builder
    • build

      public LayerNorm build()
      Builds a LayerNorm block.
      Returns:
      the LayerNorm block