Binary Cross-Entropy Loss
Beginner classical-mlclassificationloss-functions
Implement:
def bce_loss(p: np.ndarray, y: np.ndarray) -> float:
"""
p: predicted probabilities, shape (n_samples,)
y: true labels (0 or 1), shape (n_samples,)
Returns a single scalar.
"""
Your function should:
- Clip
p away from exactly 0 or 1 before taking a log.
- Return the mean BCE across all samples as a Python float.