license import * as tf from '@tensorflow/tfjs' ; import { layer , modelSummary } from './model' ; describe ( 'modelSummary' , ( ) => { beforeEach ( ( ) => { document . body . innerHTML = '<div id="container"></div>' ; } ) ; it ( 'renders a model summary' , async ( ) => { const container = { name : 'Test' } ; const model = tf . sequential ( ) ; model . add ( tf . layers . dense ( { units : 1 , inputShape : [ 1 ] } ) ) ; await modelSummary ( container , model ) ; expect ( document . querySelectorAll ( 'table' ) . length ) . toBe ( 1 ) ; expect ( document . querySelectorAll ( 'tr' ) . length ) . toBe ( 2 ) ; } ) ; } ) ; describe ( 'layer' , ( ) => { beforeEach ( ( ) => { document . body . innerHTML = '<div id="container"></div>' ; } ) ; it ( 'renders a layer summary' , async ( ) => { const container = { name : 'Test' } ; const model = tf . sequential ( ) ; const dense = tf . layers . dense ( { units : 1 , inputShape : [ 1 ] } ) ; model . add ( dense ) ; model . compile ( { optimizer : 'sgd' , loss : 'meanSquaredError' } ) ; await layer ( container , dense ) ; expect ( document . querySelectorAll ( 'table' ) . length ) . toBe ( 1 ) ; expect ( document . querySelectorAll ( 'tr' ) . length ) . toBe ( 3 ) ; } ) ; } ) ;