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

Function getProgressBarCallbackConfig

mnist-transfer-cnn/ui.js:67–97  ·  view source on GitHub ↗
(epochs)

Source from the content-addressed store, hash-verified

65}
66
67export function getProgressBarCallbackConfig(epochs) {
68 // Custom callback for updating the progress bar at the end of epochs.
69
70 const trainProg = document.getElementById('trainProg');
71 let beginMillis;
72 const progressBarCallbackConfig = {
73 onTrainBegin: async (logs) => {
74 beginMillis = tf.util.now();
75 status(
76 'Please wait and do NOT click anything while the model retrains...',
77 'blue');
78 trainProg.value = 0;
79 },
80 onTrainEnd: async (logs) => {
81 // allow retraining again
82 document.getElementById('retrain').disabled = false;
83 status(
84 `Done retraining ${epochs} epochs (elapsed: ` +
85 `${(tf.util.now() - beginMillis).toFixed(1)} ms` +
86 `). Standing by.`,
87 'black');
88 },
89 onEpochEnd: async (epoch, logs) => {
90 status(
91 `Please wait and do NOT click anything while the model ` +
92 `retrains... (Epoch ${epoch + 1} of ${epochs})`);
93 trainProg.value = (epoch + 1) / epochs * 100;
94 },
95 };
96 return progressBarCallbackConfig;
97}
98
99export function setPredictError(text) {
100 const predictHeader = document.getElementById('predict-header');

Callers

nothing calls this directly

Calls 1

statusFunction · 0.70

Tested by

no test coverage detected