(data, log)
| 76 | |
| 77 | // Train the model. |
| 78 | export async function train(data, log) { |
| 79 | const returnCost = true; |
| 80 | |
| 81 | for (let i = 0; i < TRAIN_STEPS; i++) { |
| 82 | const cost = optimizer.minimize(() => { |
| 83 | const batch = data.nextTrainBatch(BATCH_SIZE); |
| 84 | return loss(batch.labels, model(batch.xs)); |
| 85 | }, returnCost); |
| 86 | |
| 87 | log(cost.dataSync(), i); |
| 88 | await tf.nextFrame(); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | // Predict the digit number from a batch of input images. |
| 93 | export function predict(x) { |
nothing calls this directly
no test coverage detected