Files
new/export_model.py
e2hang c9b96885a8 ops
2026-04-25 00:33:33 +08:00

22 lines
684 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import torch
def export_model():
print("正在读取庞大的训练存档...")
# 读取你那个 2.7GB 的存档
huge_ckpt = torch.load("checkpoints/latest_ckpt.pt", map_location="cpu")
# 提取出纯纯的模型权重(只有 450 KB
pure_model_weights = huge_ckpt["model_state_dict"]
# 将纯权重保存给 Botzone 用
deploy_path = "botzone_cfr_net.pt"
torch.save(pure_model_weights, deploy_path)
print(f"瘦身成功!纯模型已保存为: {deploy_path}")
import os
size_kb = os.path.getsize(deploy_path) / 1024
print(f"真实模型体积: {size_kb:.2f} KB")
if __name__ == "__main__":
export_model()