medium primitives

Implement Binary Cross-Entropy Loss

Implement the Binary Cross-Entropy (BCE) loss function.

$$\text{BCE} = -\frac{1}{n} \sum_{i=1}^{n} \left[ y_i \log(\hat{y}_i) + (1 - y_i) \log(1 - \hat{y}_i) \right]$$

Input: Two 1D tensors y_true (binary labels) and y_pred (predicted probabilities in $(0,1)$)

Output: A scalar tensor representing the mean binary cross-entropy loss

Note: Add a small epsilon (1e-7) to avoid log(0).

Hints

loss classification binary
Detecting runtime...