import { ClassWeight , LayersModel , Scalar , Tensor } from '@tensorflow/tfjs-node' ; export type ModelEvaluation = { loss : number ; accuracy : number ; } ; export class ModelManager { constructor ( readonly model ) { } async train ( x , y , args ) { await this . model . fit ( x , y , args ) ; } evaluate ( x , y ) { const [ loss , accuracy ] = this . model . evaluate ( x , y ) as Scalar [ ] ; return Promise . resolve ( { loss : loss . arraySync ( ) , accuracy : accuracy . arraySync ( ) , } ) ; } predict ( x ) { return this . model . predict ( x ) as Tensor ; } }