use crate::ml::autograd;
use crate::runtime::KernelId;
use crate::{Matrix, Result};
use super::common::{mean_pointwise_loss, pointwise_loss_backward};
pub fn bce(prediction: &Matrix, target: &Matrix) -> Result<Matrix> {
let output = mean_pointwise_loss(
prediction,
target,
KernelId::MlBceF32,
crate::core::operation::ml::BCE,
)?;
autograd::record_bce(prediction, target, &output)?;
Ok(output)
}
pub(in crate::ml) fn bce_backward(prediction: &Matrix, target: &Matrix) -> Result<Matrix> {
pointwise_loss_backward(
prediction,
target,
KernelId::MlBceBackwardF32,
crate::core::operation::ml::BCE_BACKWARD,
)
}