Zaktualizuj 'ml_pytorch_mlflow.py'

This commit is contained in:
Sebastian Wałęsa 2022-05-15 14:22:58 +02:00
parent 0728bec2c0
commit 8831f8e67b

View File

@ -148,17 +148,17 @@ def my_main(epochs):
file.write(str(predict_single(input_, target, model))) file.write(str(predict_single(input_, target, model)))
input_example = val_ds[0] input_example = val_ds[0]
signature = mlflow.models.signature.infer_signature(input_, prediction(input_, model)) input_example = input_example.unsqueeze(0)
signature = mlflow.models.signature.infer_signature(input_, prediction(input_example, model))
tracking_url_type_store = urlparse(mlflow.get_tracking_uri()).scheme tracking_url_type_store = urlparse(mlflow.get_tracking_uri()).scheme
if tracking_url_type_store != "file": if tracking_url_type_store != "file":
mlflow.pytorch.log_model(model, "model", registered_model_name="s444356", signature=siganture, mlflow.pytorch.log_model(model, "model", registered_model_name="s478839", signature=siganture,
input_example=input_example) input_example=input_example)
else: else:
mlflow.pytorch.log_model(model, "model", signature=siganture, input_example=input_example) mlflow.pytorch.log_model(model, "model", signature=siganture, input_example=input_example)
mlflow.pytorch.save_model(model, "my_model", signature=siganture, input_example=input_example) mlflow.pytorch.save_model(model, "my_model", signature=siganture, input_example=input_example)
torch.save(model, "Model_xPosition.pkl")
with mlflow.start_run() as run: with mlflow.start_run() as run:
my_main(epochs) my_main(epochs)