Update modeling_minGRULM.py
Browse files- modeling_minGRULM.py +6 -0
modeling_minGRULM.py
CHANGED
@@ -46,6 +46,12 @@ class MinGRULMPreTrainedModel(PreTrainedModel):
|
|
46 |
elif isinstance(module, nn.LayerNorm):
|
47 |
module.bias.data.zero_()
|
48 |
module.weight.data.fill_(1.0)
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
|
51 |
class MinGRULMForCausalLM(PreTrainedModel):
|
|
|
46 |
elif isinstance(module, nn.LayerNorm):
|
47 |
module.bias.data.zero_()
|
48 |
module.weight.data.fill_(1.0)
|
49 |
+
|
50 |
+
# NaN kontrolü: Tüm parametrelerde NaN varsa, sıfırlama
|
51 |
+
for name, param in module.named_parameters():
|
52 |
+
if torch.isnan(param).any():
|
53 |
+
print(f"NaN detected in parameter {name}. Replacing with zeros.")
|
54 |
+
param.data = torch.nan_to_num(param.data, nan=0.0)
|
55 |
|
56 |
|
57 |
class MinGRULMForCausalLM(PreTrainedModel):
|