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

Function main

quantization/eval_housing.js:45–75  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

43}
44
45async 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
77if (require.main === module) {
78 main();

Callers 1

eval_housing.jsFile · 0.70

Calls 4

getDatasetStatsFunction · 0.90
getNormalizedDatasetsFunction · 0.90
compileModelFunction · 0.90
parseArgsFunction · 0.70

Tested by

no test coverage detected