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

Function determineMeanAndStddev

boston-housing/normalization.js:27–35  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

25 * column as 1d tensors.
26 */
27export function determineMeanAndStddev(data) {
28 const dataMean = data.mean(0);
29 // TODO(bileschi): Simplify when and if tf.var / tf.std added to the API.
30 const diffFromMean = data.sub(dataMean);
31 const squaredDiffFromMean = diffFromMean.square();
32 const variance = squaredDiffFromMean.mean(0);
33 const dataStd = variance.sqrt();
34 return {dataMean, dataStd};
35}
36
37/**
38 * Given expected mean and standard deviation, normalizes a dataset by

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected