← 返回刚才阅读的位置

知识卡片

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

独立样本状态通常应重新初始化

理解等级:中级

每条独立文本开始时将隐藏状态清零,可避免上一样本内容影响当前判断。初始状态也可学习或有约定常数,但训练与推断要一致,设备和dtype要匹配;自定义图案不自动产生可解释坐标。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • · 查看原书依据

      ... hidden = torch.zeros(1, model.n_hidden) #1 ... model.zero_grad() #2 ... for char_onehot_vector in char_seq_tens: ... category_predictions, hidden = model( #3 ... x=char_onehot_vector, hidden=hidden) #4 ... loss = criterion(category_predictions, category_tensor) ... loss.backward() ... for p in model.parameters(): ... p.data.add_(p.grad.data, alpha=-lr) ... return model, category_predictions, loss.item() #1 Initializes the hidden layer to zeros before computing the output for the first token #2 An RNN starts fresh at

    参考来源

    - 位置:《Natural Language Processing in Action, Second Edition》第08章《循环网络与长短期记忆》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Natural Language Processing in Action, Second Edition/_epub-src/OEBPS/Text/chapter-8.html) - 结论依据:摘录中关于独立样本状态通常应重新初始化的定义、比较或条件支撑卡片;原书表述不严谨的范围已在覆盖记录逐项限定,不把案例结果外推为普遍结论。 - 原始内容:... hidden = torch.zeros(1, model.n_hidden) #1 ... model.zero_grad() #2 ... for char_onehot_vector in char_seq_tens: ... category_predictions, hidden = model( #3 ... x=char_onehot_vector, hidden=hidden) #4 ... loss = criterion(category_predictions, category_tensor) ... loss.backward() ... for p in model.parameters(): ... p.data.add_(p.grad.data, alpha=-lr) ... return model, category_predictions, loss.item() #1 Initializes the hidden layer to zeros before computing the output for the first token #2 An RNN starts fresh at