MCPcopy
hub / github.com/tensorflow/tfjs / meanSquaredLogErrorFor1DArray

Function meanSquaredLogErrorFor1DArray

tfjs-layers/src/losses_test.ts:78–88  ·  view source on GitHub ↗
(x: number[], y: number[])

Source from the content-addressed store, hash-verified

76
77describeMathCPUAndGPU('meanSquaredLogarithmicError', () => {
78 function meanSquaredLogErrorFor1DArray(x: number[], y: number[]): number {
79 const calcLog = (val: number) => Math.log(Math.max(val, epsilon()) + 1);
80 const logX = x.map(calcLog);
81 const logY = y.map(calcLog);
82 let acc = 0.0;
83 for (let i = 0; i < x.length; i++) {
84 const diff = logX[i] - logY[i];
85 acc += diff * diff;
86 }
87 return acc / x.length;
88 }
89
90 it('2D', () => {
91 const yTrue = tfc.zeros([2, 2]);

Callers 1

losses_test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…