(args?: LayerNormalizationLayerArgs)
| 487 | private beta: LayerVariable; |
| 488 | |
| 489 | constructor(args?: LayerNormalizationLayerArgs) { |
| 490 | if (args == null) { |
| 491 | args = {}; |
| 492 | } |
| 493 | super(args); |
| 494 | |
| 495 | this.axis = args.axis == null ? -1 : args.axis; |
| 496 | if (typeof this.axis === 'number') { |
| 497 | if (!Number.isInteger(this.axis)) { |
| 498 | throw new Error( |
| 499 | `Expected axis to be an integer, but received ${this.axis}`); |
| 500 | } |
| 501 | } else if (Array.isArray(this.axis)) { |
| 502 | for (const axis of this.axis) { |
| 503 | if (!Number.isInteger(axis)) { |
| 504 | throw new Error( |
| 505 | `Expected axis to be an array of integers, ` + |
| 506 | `but received ${JSON.stringify(this.axis)}`); |
| 507 | } |
| 508 | } |
| 509 | } else { |
| 510 | throw new Error( |
| 511 | `Expected axis to be an integer or an array of integers, ` + |
| 512 | `but received ${JSON.stringify(this.axis)}`); |
| 513 | } |
| 514 | |
| 515 | this.epsilon = args.epsilon == null ? 1e-3 : args.epsilon; |
| 516 | this.center = args.center == null ? true : args.center; |
| 517 | this.scale = args.scale == null ? true : args.scale; |
| 518 | this.betaInitializer = getInitializer(args.betaInitializer || 'zeros'); |
| 519 | this.gammaInitializer = getInitializer(args.gammaInitializer || 'ones'); |
| 520 | this.betaRegularizer = getRegularizer(args.betaRegularizer); |
| 521 | this.gammaRegularizer = getRegularizer(args.gammaRegularizer); |
| 522 | |
| 523 | this.supportsMasking = true; |
| 524 | } |
| 525 | |
| 526 | public override build(inputShape: Shape|Shape[]): void { |
| 527 | inputShape = getExactlyOneShape(inputShape); |
nothing calls this directly
no test coverage detected