UNPKG

@hoff97/tensor-js

Version:

PyTorch like deep learning inferrence library

15 lines (14 loc) 524 B
import { Tensor } from '../../../library'; import { DType } from '../../../types'; /** * Calculates the binary cross entropy loss, given probabilities x * and ground truth y. Returns a tensor of the same shape as * x. To use for a loss, you have to sum over the result: * ```typescript * const loss = bce(x,y).sum(); * ``` * * @param x Probabilities in [0,1] * @param y Ground truth labels of the same shape as x. */ export declare function bce<DTpe extends DType>(x: Tensor<DTpe>, y: Tensor<DTpe>): Tensor<DTpe>;