Skip to main content

Model export

PyTorch

torch.save()

In official documents saving_loading_models Introduction through torch.save() Save the model as .pth perhaps .pt Format for suffixes.

ONNX

PyTorch Also supported through torch.onnx.export() Convert it to .onnx Format file. In official documents TORCH.ONNX I also provided a detailed introduction.

XGBoost

Pickle

XGBoost The model can be directly used pickle export.

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

Booster.save_model()

XGBoost Booster Models can also be used Booster.save_model() Method export, stay [file](https://xgboost.readthedocs.io/en/latest/python/python_api.html#xgboost. Booster.save_model) There are detailed explanations available. But using this method. Booster The additional attributes recorded in will not be retained. Do you want to keep it or recommend using the above pickle method.

model.save_model("model.bin")

ONNX

XGBoost Can be used onnxmltools Export as onnx format.