L1aoXingyu/code-of-learn-deep-learning-with-pytorch

loss function in "logistic-regression.ipynb "

wanpiqiu123 opened this issue · 2 comments

计算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()

均值的括号是在最外面,不是只对最后一个部分求mean

感谢!