Spaces:
Runtime error
Runtime error
Update init_save.py
Browse files- init_save.py +7 -17
init_save.py
CHANGED
@@ -1,19 +1,9 @@
|
|
|
|
1 |
import os
|
2 |
-
import torch
|
3 |
-
from evo_model import EvoTransformerForClassification, EvoTransformerConfig
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
model
|
11 |
-
|
12 |
-
# β
Save like Hugging Face expects
|
13 |
-
torch.save(model.state_dict(), "trained_model/pytorch_model.bin")
|
14 |
-
|
15 |
-
# β
Save minimal config
|
16 |
-
with open("trained_model/config.json", "w") as f:
|
17 |
-
f.write(config.to_json_string())
|
18 |
-
|
19 |
-
print("β
EvoTransformer initial model saved to 'trained_model/'")
|
|
|
1 |
+
from evo_model import EvoTransformerConfig, EvoTransformerForClassification
|
2 |
import os
|
|
|
|
|
3 |
|
4 |
+
def initialize_and_save_model(save_path="trained_model"):
|
5 |
+
config = EvoTransformerConfig()
|
6 |
+
model = EvoTransformerForClassification(config)
|
7 |
+
|
8 |
+
os.makedirs(save_path, exist_ok=True)
|
9 |
+
model.save_pretrained(save_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|