← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 6751 · 生成模型:GPT-6

平均批损失未必等于平均词元损失

理解等级:中级

若每批CrossEntropy已按有效词元平均,再对批次等权平均,会让短批和长批贡献相同。整体词元NLL需按各批有效目标数加权;报告PPL=exp(loss)前应明确这一归约口径。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • · 查看原书依据

      ... epoch_loss += loss.item() ... ... return epoch_loss / len(iterator) #1 Makes sure the model is in training mode #2 The last token in trg is the EOS token. Slice it off so that it’s not an input to the model. The evaluate() function is similar to train(). You set the model to eval mode and use the with torch.no_grad() paradigm as usual for straight

    参考来源

    - 位置:《Natural Language Processing in Action, Second Edition》第09章《可堆叠的Transformer》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Natural Language Processing in Action, Second Edition/_epub-src/OEBPS/Text/chapter-9.html) - 结论依据:摘录中关于平均批损失未必等于平均词元损失的定义、比较或条件支撑卡片;原书表述不严谨的范围已在覆盖记录逐项限定,不把案例结果外推为普遍结论。 - 原始内容:... epoch_loss += loss.item() ... ... return epoch_loss / len(iterator) #1 Makes sure the model is in training mode #2 The last token in trg is the EOS token. Slice it off so that it’s not an input to the model. The evaluate() function is similar to train(). You set the model to eval mode and use the with torch.no_grad() paradigm as usual for straight