* Run inference on some test Iris flower data. * * @param model The instance of `tf.Model` to run the inference with. * @param xTest Test data feature, a `tf.Tensor` of shape [numTestExamples, 4]. * @param yTest Test true labels, one-hot encoded, a `tf.Tensor` of shape * [numTestExamples, 3].
(model, xTest, yTest)
| 143 | * [numTestExamples, 3]. |
| 144 | */ |
| 145 | async function evaluateModelOnTestData(model, xTest, yTest) { |
| 146 | ui.clearEvaluateTable(); |
| 147 | |
| 148 | tf.tidy(() => { |
| 149 | const xData = xTest.dataSync(); |
| 150 | const yTrue = yTest.argMax(-1).dataSync(); |
| 151 | const predictOut = model.predict(xTest); |
| 152 | const yPred = predictOut.argMax(-1); |
| 153 | ui.renderEvaluateTable( |
| 154 | xData, yTrue, yPred.dataSync(), predictOut.dataSync()); |
| 155 | calculateAndDrawConfusionMatrix(model, xTest, yTest); |
| 156 | }); |
| 157 | |
| 158 | predictOnManualInput(model); |
| 159 | } |
| 160 | |
| 161 | const HOSTED_MODEL_JSON_URL = |
| 162 | 'https://storage.googleapis.com/tfjs-models/tfjs/iris_v1/model.json'; |
no test coverage detected