Binary Cross Entropy Explained - Sparrow Computing
sparrow.dev › binary-cross-entropyFeb 22, 2021 · def binary_cross_entropy(yhat: np.ndarray, y: np.ndarray) -> float: """Compute binary cross-entropy loss for a vector of predictions Parameters ----- yhat An array with len(yhat) predictions between [0, 1] y An array with len(y) labels where each is one of {0, 1} """ return -(y * np.log(yhat) + (1 - y) * np.log(1 - yhat)).mean()