loss function in "logistic-regression.ipynb "
wanpiqiu123 opened this issue · 2 comments
wanpiqiu123 commented
计算loss的函数:
def binary_loss(y_pred, y):
logits = (y * y_pred.clamp(1e-12).log() + (1 - y) * (1 - y_pred).clamp(1e-12).log()).mean()
return -logits
前半部分是不是应该使用平均值?即
logits = (y * y_pred.clamp(1e-12).log().mean() + (1 - y) * (1 - y_pred).clamp(1e-12).log()).mean()
L1aoXingyu commented
均值的括号是在最外面,不是只对最后一个部分求mean
wanpiqiu123 commented
感谢!