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

Function klElement

tfjs-layers/src/losses_test.ts:335–339  ·  view source on GitHub ↗
(actual: number, predicted: number)

Source from the content-addressed store, hash-verified

333
334describeMathCPUAndWebGL2('kullbackLeiblerDivergence', () => {
335 function klElement(actual: number, predicted: number): number {
336 actual = Math.max(actual, epsilon());
337 predicted = Math.max(predicted, epsilon());
338 return actual * Math.log(actual / predicted);
339 }
340
341 it('2D', () => {
342 const yTrue = tensor2d([[1, 0], [1, 0]], [2, 2]);

Callers 1

losses_test.tsFile · 0.85

Calls 3

epsilonFunction · 0.90
maxMethod · 0.80
logMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…