Fix CaduceusForSequenceClassification scorer init
Browse files- modeling_caduceus.py +6 -0
modeling_caduceus.py
CHANGED
|
@@ -538,6 +538,12 @@ class CaduceusForSequenceClassification(CaduceusPreTrainedModel):
|
|
| 538 |
|
| 539 |
# Initialize weights and apply final processing
|
| 540 |
self.post_init()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 541 |
|
| 542 |
def get_input_embeddings(self):
|
| 543 |
return self.caduceus.backbone.embeddings.word_embeddings
|
|
|
|
| 538 |
|
| 539 |
# Initialize weights and apply final processing
|
| 540 |
self.post_init()
|
| 541 |
+
self.init_scorer()
|
| 542 |
+
|
| 543 |
+
def init_scorer(self, initializer_range=0.02):
|
| 544 |
+
initializer_range = self.config.initializer_cfg.get("initializer_range", initializer_range) \
|
| 545 |
+
if self.config.initializer_cfg is not None else initializer_range
|
| 546 |
+
self.score.weight.data.normal_(std=initializer_range)
|
| 547 |
|
| 548 |
def get_input_embeddings(self):
|
| 549 |
return self.caduceus.backbone.embeddings.word_embeddings
|