Upload MRIBrainSequenceBERT
Browse files- config.json +2 -2
- modeling.py +3 -4
config.json
CHANGED
|
@@ -7,9 +7,9 @@
|
|
| 7 |
"AutoModel": "modeling.MRIBrainSequenceBERT"
|
| 8 |
},
|
| 9 |
"dropout": 0.2,
|
|
|
|
| 10 |
"max_len": 512,
|
| 11 |
"model_type": "mri_brain_sequence_bert",
|
| 12 |
"num_classes": 16,
|
| 13 |
-
"
|
| 14 |
-
"transformers_version": "4.47.0"
|
| 15 |
}
|
|
|
|
| 7 |
"AutoModel": "modeling.MRIBrainSequenceBERT"
|
| 8 |
},
|
| 9 |
"dropout": 0.2,
|
| 10 |
+
"dtype": "float32",
|
| 11 |
"max_len": 512,
|
| 12 |
"model_type": "mri_brain_sequence_bert",
|
| 13 |
"num_classes": 16,
|
| 14 |
+
"transformers_version": "4.57.3"
|
|
|
|
| 15 |
}
|
modeling.py
CHANGED
|
@@ -17,16 +17,15 @@ class MRIBrainSequenceBERT(PreTrainedModel):
|
|
| 17 |
|
| 18 |
def __init__(self, config):
|
| 19 |
super().__init__(config)
|
| 20 |
-
self.
|
| 21 |
-
|
| 22 |
-
)
|
| 23 |
self.dim_feats = self.llm.classifier.in_features
|
| 24 |
self.dropout = nn.Dropout(p=config.dropout)
|
| 25 |
self.classifier = nn.Linear(self.dim_feats, config.num_classes)
|
| 26 |
self.llm.dropout = nn.Identity()
|
| 27 |
self.llm.classifier = nn.Identity()
|
| 28 |
|
| 29 |
-
self.tokenizer = AutoTokenizer.from_pretrained(
|
| 30 |
self.max_len = config.max_len
|
| 31 |
|
| 32 |
self.metadata_elements = [
|
|
|
|
| 17 |
|
| 18 |
def __init__(self, config):
|
| 19 |
super().__init__(config)
|
| 20 |
+
self.model_id = "answerdotai/ModernBERT-base"
|
| 21 |
+
self.llm = AutoModelForSequenceClassification.from_pretrained(self.model_id)
|
|
|
|
| 22 |
self.dim_feats = self.llm.classifier.in_features
|
| 23 |
self.dropout = nn.Dropout(p=config.dropout)
|
| 24 |
self.classifier = nn.Linear(self.dim_feats, config.num_classes)
|
| 25 |
self.llm.dropout = nn.Identity()
|
| 26 |
self.llm.classifier = nn.Identity()
|
| 27 |
|
| 28 |
+
self.tokenizer = AutoTokenizer.from_pretrained(self.model_id)
|
| 29 |
self.max_len = config.max_len
|
| 30 |
|
| 31 |
self.metadata_elements = [
|