Skip to content

A programming framework for agentic AI

Fix checkpoint path issue

Jing Dong5778227a7143
diff --git a/website/docs/Examples/Tune-PyTorch.md b/website/docs/Examples/Tune-PyTorch.md
index 83f38e609..d75c716c7 100644
--- a/website/docs/Examples/Tune-PyTorch.md
+++ b/website/docs/Examples/Tune-PyTorch.md
@@ -261,7 +261,8 @@ if torch.cuda.is_available():
best_trained_model = nn.DataParallel(best_trained_model)
best_trained_model.to(device)
-checkpoint_path = os.path.join(best_trial.checkpoint.value, "checkpoint")
+checkpoint_value = getattr(best_trial.checkpoint, "dir_or_data", None) or best_trial.checkpoint.value
+checkpoint_path = os.path.join(checkpoint_value, "checkpoint")
model_state, optimizer_state = torch.load(checkpoint_path)
best_trained_model.load_state_dict(model_state)
@@ -283,4 +284,4 @@ Files already downloaded and verified
Best trial test set accuracy: 0.6294
```
-[Link to notebook](https://github.com/microsoft/FLAML/blob/main/notebook/tune_pytorch.ipynb) | [Open in colab](https://colab.research.google.com/github/microsoft/FLAML/blob/main/notebook/tune_pytorch.ipynb)
\ No newline at end of file
+[Link to notebook](https://github.com/microsoft/FLAML/blob/main/notebook/tune_pytorch.ipynb) | [Open in colab](https://colab.research.google.com/github/microsoft/FLAML/blob/main/notebook/tune_pytorch.ipynb)