OneScience/FuXi main
PYTHON
Verdict: BENIGN
Local reference
Suspicious dependency
Inferred
| 1 |
import sys
|
|
| 2 |
from pathlib import Path
|
|
| 3 |
|
|
| 4 |
# 获取项目根目录(train.py上级的上级)
|
|
| 5 |
root_path = Path(__file__).parent.parent
|
|
| 6 |
sys.path.append(str(root_path))
|
|
| 7 |
import torch
|
|
| 8 |
import os
|
|
| 9 |
import numpy as np
|
|
| 10 |
import torch.distributed as dist
|
|
| 11 |
import logging
|
|
| 12 |
import time
|
|
| 13 |
|
|
| 14 |
from tqdm import tqdm
|
|
| 15 |
from torch.nn.parallel import DistributedDataParall… |
|
| 42:2 |
… world_rank = dist.get_rank()
|
|
| 43 |
if not os.path.exists(f"{cfg.checkpoint_dir}/model_short_bak.pth"):
|
Checkpoint extension after model context |
| 44 |
if world_rank == 0:
|
|
| 45 |
print(f'❌❌The Fuxi short model must be trained before this model.')
|
|
| 46 |
e… |
|
| 86:70 |
…o(local_rank)
|
|
| 87 |
|
|
| 88 |
## Train process init
|
|
| 89 |
os.makedirs(cfg.checkpoint_dir, exist_ok=True)
|
|
| 90 |
train_loss_file = f"{cfg.checkpoint_dir}/tr_medium_loss.npy"
|
|
| 91 |
valid_loss_file = f"{cfg.checkpoint_dir}/va_medium_loss.npy"
|
|
| 92 |
best_valid_loss = 1.0e6
|
|
| 93 |
best_loss_epoch = 0
|
|
| 94 |
t… |
|
| 118:28 |
…want to finetune a new model, ensure there is no model_short_bak.pth file in {cfg.checkpoint_dir}')
|
Checkpoint extension before model context |
| 119 |
print("-" * 50, "\n")
|
|
| 120 |
ckpt = torch.load(f"{cfg.checkpoint_dir}/model_medium_bak.pth", map_location=f'cuda:{local_rank}', weights_only=False)
|
Loads a PyTorch checkpoint |
| 121 |
model.load_state_… |
|
| 278:66 |
…imit, get a backup to ensure there at least has one model
|
|
| 279 |
os.system(f"mv {model_path}/model_medium.pth {model_path}/model_medium_bak.pth")
|
Executes shell commands via Python |
| 280 |
|
|
| 281 |
|
|
| 282 |
if __name__ == "__main__":
|
|
| 283 |
current_path = os.getcwd()
|
Calls Python os.getcwd |
| 284 |
sys.path.append(current_path)
|
|
| 285 |
main() |
|
Identity
| SHA-256 |
05b4fc564fe047b5fc7e4202e2dc33ae2d26a71769639ad8efa250b285a3f8db |
| Filename |
train_medium.py |
| Package |
OneScience/FuXi |
| Version |
main |
| PURL |
pkg:huggingface/OneScience/FuXi@main |
Timeline
| First seen |
24 Jul 2026 09:18 UTC |
| First analyzed |
2 Aug 2026 17:44 UTC |
| Last analyzed |
2 Aug 2026 17:44 UTC |
| Last updated |
2 Aug 2026 17:44 UTC |
Labeling
| Label |
unknown |
| Label source |
forager |
| Traits version |
d9759 |