style: 修改为显式导入

This commit is contained in:
2026-04-04 16:02:49 +08:00
parent 3346c75584
commit b531232a9b
12 changed files with 38 additions and 34 deletions
+3 -3
View File
@@ -94,7 +94,7 @@ class Transformer(nn.Module):
self.norm = RMSNorm(config.dim, config.norm_eps)
self.lm_head = Linear(config.dim, config.vocab_size)
if self.config.tie_weight == True:
if self.config.tie_weight:
self.lm_head.weight = self.embed_tokens.weight
self._init_parameters()
@@ -103,7 +103,7 @@ class Transformer(nn.Module):
lm_head_key = "lm_head.weight"
embed_key = "embed_tokens.weight"
if self.config.tie_weight == True:
if self.config.tie_weight:
# same tensor
state_dict[lm_head_key] = state_dict[embed_key]
else:
@@ -118,7 +118,7 @@ class Transformer(nn.Module):
destination=destination, prefix=prefix, keep_vars=keep_vars
)
if self.config.tie_weight == True:
if self.config.tie_weight:
lm_head_key = prefix + "lm_head.weight"
if lm_head_key in state_dict:
del state_dict[lm_head_key]