MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / train

Function train

mnist-core/model.js:78–90  ·  view source on GitHub ↗
(data, log)

Source from the content-addressed store, hash-verified

76
77// Train the model.
78export 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.
93export function predict(x) {

Callers

nothing calls this directly

Calls 3

modelFunction · 0.85
lossFunction · 0.70
nextTrainBatchMethod · 0.45

Tested by

no test coverage detected