()
| 43 | } |
| 44 | |
| 45 | async function main() { |
| 46 | const args = parseArgs(); |
| 47 | if (args.gpu) { |
| 48 | tf = require('@tensorflow/tfjs-node-gpu'); |
| 49 | } else { |
| 50 | tf = require('@tensorflow/tfjs-node'); |
| 51 | } |
| 52 | |
| 53 | const {count, featureMeans, featureStddevs, labelMean, labelStddev} = |
| 54 | await getDatasetStats(); |
| 55 | |
| 56 | const validationSplit = 0.2; |
| 57 | const evaluationSplit = 0.1; |
| 58 | const {evalXs, evalYs} = |
| 59 | await getNormalizedDatasets( |
| 60 | count, featureMeans, featureStddevs, labelMean, labelStddev, |
| 61 | validationSplit, evaluationSplit); |
| 62 | |
| 63 | console.log(`Loading model from ${args.modelSavePath}...`); |
| 64 | const model = await tf.loadLayersModel(`file://${args.modelSavePath}`); |
| 65 | compileModel(model); |
| 66 | |
| 67 | console.log(`Performing evaluation...`); |
| 68 | const t0 = tf.util.now(); |
| 69 | const evalOutput = model.evaluate(evalXs, evalYs); |
| 70 | const t1 = tf.util.now(); |
| 71 | console.log(`\nEvaluation took ${(t1 - t0).toFixed(2)} ms.`); |
| 72 | console.log( |
| 73 | `\nEvaluation result:\n` + |
| 74 | ` Loss = ${evalOutput.dataSync()[0].toFixed(6)}`); |
| 75 | } |
| 76 | |
| 77 | if (require.main === module) { |
| 78 | main(); |
no test coverage detected