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

Function _binaryCrossentropy

tfjs-layers/src/losses_test.ts:315–323  ·  view source on GitHub ↗
(target: Tensor, output: Tensor)

Source from the content-addressed store, hash-verified

313
314describeMathCPUAndGPU('binaryCrossentropy', () => {
315 function _binaryCrossentropy(target: Tensor, output: Tensor): Tensor {
316 const targetComplement = tfc.add(scalar(1), tfc.neg(target));
317 const outputComplement = tfc.add(scalar(1), tfc.neg(output));
318 return tfc.mean(
319 tfc.neg(tfc.add(
320 tfc.mul(target, tfc.log(output)),
321 tfc.mul(targetComplement, tfc.log(outputComplement)))),
322 -1);
323 }
324
325 it('from sigmoid', () => {
326 const x = tensor2d([[0.3, 0.7], [0.4, 0.6]], [2, 2]);

Callers 1

losses_test.tsFile · 0.85

Calls 6

scalarFunction · 0.90
negMethod · 0.80
meanMethod · 0.80
mulMethod · 0.80
addMethod · 0.65
logMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…