model.py 中的拼写错误
作者: Anthony6075创建于 2026年6月2日更新于 2026年6月2日
初始化所有权重
self.apply(self._init_weights)
根据 GPT-2 论文中的信息,对残差投影应用特殊的缩放初始化
for pn, p in self.named_parameters(): if pn.endswith('w3.weight') or pn.endswith('wo.weight'): torch.nn.init.normal_(p, mean=0.0, std=0.02 / math.sqrt(2 * params.n_layers))
内容来源: karpathy/llama2.c