(inputShape: Shape|Shape[])
| 296 | } |
| 297 | |
| 298 | public override build(inputShape: Shape|Shape[]): void { |
| 299 | inputShape = getExactlyOneShape(inputShape); |
| 300 | const axis = this.axis >= 0 ? this.axis : (this.axis + inputShape.length); |
| 301 | const dim = inputShape[axis]; |
| 302 | if (dim == null) { |
| 303 | throw new ValueError( |
| 304 | `Axis ${axis} of input tensor should have a defined dimension but ` + |
| 305 | `the layer received an input with shape ` + |
| 306 | `${JSON.stringify(inputShape)}.`); |
| 307 | } |
| 308 | this.inputSpec = |
| 309 | [new InputSpec({ndim: inputShape.length, axes: {[axis]: dim}})]; |
| 310 | const shape = [dim]; |
| 311 | if (this.scale) { |
| 312 | this.gamma = this.addWeight( |
| 313 | 'gamma', shape, null, this.gammaInitializer, this.gammaRegularizer, |
| 314 | true, this.gammaConstraint); |
| 315 | } |
| 316 | if (this.center) { |
| 317 | this.beta = this.addWeight( |
| 318 | 'beta', shape, null, this.betaInitializer, this.betaRegularizer, true, |
| 319 | this.betaConstraint); |
| 320 | } |
| 321 | this.movingMean = this.addWeight( |
| 322 | 'moving_mean', shape, null, this.movingMeanInitializer, null, false); |
| 323 | this.movingVariance = this.addWeight( |
| 324 | 'moving_variance', shape, null, this.movingVarianceInitializer, null, |
| 325 | false); |
| 326 | this.built = true; |
| 327 | } |
| 328 | |
| 329 | override call(inputs: Tensor|Tensor[], kwargs: Kwargs): Tensor|Tensor[] { |
| 330 | return tidy(() => { |
nothing calls this directly
no test coverage detected