MCPcopy
hub / github.com/tensorflow/tfjs-examples / predict

Method predict

mnist-transfer-cnn/index.js:97–109  ·  view source on GitHub ↗
(imageText)

Source from the content-addressed store, hash-verified

95
96 // Perform prediction on the input image using the loaded model.
97 predict(imageText) {
98 tf.tidy(() => {
99 try {
100 const image = util.textToImageArray(imageText, this.imageSize);
101 const predictOut = this.model.predict(image);
102 const winner = predictOut.argMax(1);
103
104 ui.setPredictResults(predictOut.dataSync(), winner.dataSync()[0] + 5);
105 } catch (e) {
106 ui.setPredictError(e.message);
107 }
108 });
109 }
110
111 // Perform retraining on the loaded model.
112 async retrainModel() {

Callers 8

testFunction · 0.45
showPredictionsFunction · 0.45
setupMnistTransferCNNFunction · 0.45
mobilenetDemoFunction · 0.45
predictFunction · 0.45
gan_test.jsFile · 0.45

Calls

no outgoing calls

Tested by 1

testFunction · 0.36