(args: DenseLayerArgs)
| 205 | private readonly biasRegularizer?: Regularizer; |
| 206 | |
| 207 | constructor(args: DenseLayerArgs) { |
| 208 | super(args); |
| 209 | if (args.batchInputShape == null && args.inputShape == null && |
| 210 | args.inputDim != null) { |
| 211 | // This logic is copied from Layer's constructor, since we can't |
| 212 | // do exactly what the Python constructor does for Dense(). |
| 213 | let batchSize: number = null; |
| 214 | if (args.batchSize != null) { |
| 215 | batchSize = args.batchSize; |
| 216 | } |
| 217 | this.batchInputShape = [batchSize, args.inputDim]; |
| 218 | } |
| 219 | |
| 220 | this.units = args.units; |
| 221 | assertPositiveInteger(this.units, 'units'); |
| 222 | this.activation = getActivation(args.activation); |
| 223 | if (args.useBias != null) { |
| 224 | this.useBias = args.useBias; |
| 225 | } |
| 226 | this.kernelInitializer = getInitializer( |
| 227 | args.kernelInitializer || this.DEFAULT_KERNEL_INITIALIZER); |
| 228 | this.biasInitializer = |
| 229 | getInitializer(args.biasInitializer || this.DEFAULT_BIAS_INITIALIZER); |
| 230 | this.kernelConstraint = getConstraint(args.kernelConstraint); |
| 231 | this.biasConstraint = getConstraint(args.biasConstraint); |
| 232 | this.kernelRegularizer = getRegularizer(args.kernelRegularizer); |
| 233 | this.biasRegularizer = getRegularizer(args.biasRegularizer); |
| 234 | this.activityRegularizer = getRegularizer(args.activityRegularizer); |
| 235 | this.supportsMasking = true; |
| 236 | |
| 237 | this.inputSpec = [{minNDim: 2}]; |
| 238 | } |
| 239 | |
| 240 | public override build(inputShape: Shape|Shape[]): void { |
| 241 | inputShape = getExactlyOneShape(inputShape); |
nothing calls this directly
no test coverage detected