(useRegularizers: boolean)
| 419 | |
| 420 | describeMathCPUAndGPU('Container.calculateLosses', () => { |
| 421 | function createSimpleOneLayerContainer(useRegularizers: boolean): |
| 422 | [Container, Layer[]] { |
| 423 | const inputShape = [2]; |
| 424 | const inputLayer = tfl.layers.input({shape: inputShape}); |
| 425 | const kernelRegularizer = |
| 426 | useRegularizers ? tfl.regularizers.l1({l1: 2}) : null; |
| 427 | const biasRegularizer = |
| 428 | useRegularizers ? tfl.regularizers.l2({l2: 3}) : null; |
| 429 | const denseLayer = tfl.layers.dense({ |
| 430 | units: 2, |
| 431 | kernelInitializer: 'ones', |
| 432 | biasInitializer: 'ones', |
| 433 | kernelRegularizer, |
| 434 | biasRegularizer, |
| 435 | name: 'denseLayer' |
| 436 | }); |
| 437 | const layer2Output = denseLayer.apply(inputLayer) as tfl.SymbolicTensor; |
| 438 | const container = |
| 439 | new ContainerForTest({inputs: [inputLayer], outputs: [layer2Output]}); |
| 440 | return [container, [denseLayer]]; |
| 441 | } |
| 442 | |
| 443 | it('L1 and L2', () => { |
| 444 | const container = createSimpleOneLayerContainer(true)[0]; |
no test coverage detected
searching dependent graphs…