Skip to content

Commit 42ffb2a

Browse files
authored
Switch to chaining API to match Ch 2. in book. (#335)
* Switch to chaining API to match Ch 2. in book.
1 parent c203bb4 commit 42ffb2a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

boston-housing/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ export async function run(model, modelName, weightsIllustration) {
173173
};
174174

175175
export function computeBaseline() {
176-
const avgPrice = tf.mean(tensors.trainTarget);
176+
const avgPrice = tensors.trainTarget.mean();
177177
console.log(`Average price: ${avgPrice.dataSync()}`);
178-
const baseline = tf.mean(tf.pow(tf.sub(tensors.testTarget, avgPrice), 2));
178+
const baseline = tensors.testTarget.sub(avgPrice).square().mean();
179179
console.log(`Baseline loss: ${baseline.dataSync()}`);
180180
const baselineMsg = `Baseline loss (meanSquaredError) is ${
181181
baseline.dataSync()[0].toFixed(2)}`;

0 commit comments

Comments
 (0)