-
Notifications
You must be signed in to change notification settings - Fork 195
Closed
Labels
code-fixChange that does not change the behavior, such as code refactoring.Change that does not change the behavior, such as code refactoring.staleExempt from stale bot labeling.Exempt from stale bot labeling.
Description
The PyTorch checkpoint example uses temporary files, which can be replaced with tempfile.
optuna-examples/pytorch/pytorch_checkpoint.py
Lines 101 to 107 in bb14f7e
| download_artifact( | |
| artifact_store=artifact_store, | |
| file_path=f"./tmp_model_{trial.number}.pt", | |
| artifact_id=artifact_id, | |
| ) | |
| checkpoint = torch.load(f"./tmp_model_{trial.number}.pt") | |
| os.remove(f"./tmp_model_{trial.number}.pt") |
optuna-examples/pytorch/pytorch_checkpoint.py
Lines 161 to 176 in bb14f7e
| torch.save( | |
| { | |
| "epoch": epoch, | |
| "model_state_dict": model.state_dict(), | |
| "optimizer_state_dict": optimizer.state_dict(), | |
| "accuracy": accuracy, | |
| }, | |
| f"./tmp_model_{trial.number}.pt", | |
| ) | |
| artifact_id = upload_artifact( | |
| artifact_store=artifact_store, | |
| file_path=f"./tmp_model_{trial.number}.pt", | |
| study_or_trial=trial, | |
| ) | |
| trial.set_user_attr("artifact_id", artifact_id) | |
| os.remove(f"./tmp_model_{trial.number}.pt") |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
code-fixChange that does not change the behavior, such as code refactoring.Change that does not change the behavior, such as code refactoring.staleExempt from stale bot labeling.Exempt from stale bot labeling.