HyperAIHyperAI

Model Export

Introduction to exporting model files in different frameworks

PyTorch

torch.save()

The official documentation saving_loading_models introduces how to save models as files with .pth or .pt extensions using torch.save().

ONNX

PyTorch also supports converting models to .onnx format files through torch.onnx.export(). The official documentation TORCH.ONNX provides a detailed introduction.

XGBoost

pickle

XGBoost models can be exported directly using pickle.

pickle.dump(model, open("model.pkl", "wb"))

Booster.save_model()

XGBoost Booster models can also be exported using the Booster.save_model() method, which is explained in detail in the documentation. However, with this method, the additional attributes recorded in the Booster will not be preserved. To preserve them, the pickle method mentioned above is recommended.

model.save_model("model.bin")

ONNX

XGBoost can be exported to ONNX format using onnxmltools.