Skip to content

Commit

Permalink
Follow review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
HideakiImamura authored and gen740 committed Oct 6, 2023
1 parent eb71cfa commit 565210f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
3 changes: 3 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ clean:
rm -rf source/tutorial/10_key_features
rm -rf source/tutorial/20_recipes
rm -f ../tutorial/**/*.db
rm -rf ../tutorial/20_recipes/artifacts
rm -rf ../tutorial/20_recipes/tmp
rm -rf ../tutorial/20_recipes/best_atoms.png
26 changes: 10 additions & 16 deletions tutorial/20_recipes/011_artifact_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
Optuna Artifacts Tutorial
=========================
.. contents:: Table of Contents
:depth: 2
The artifact module of Optuna is a module designed for saving comparatively large attributes on a trial-by-trial basis in forms such
as files. Introduced from Optuna v3.3, this module finds a broad range of applications, such as utilizing snapshots of large size
models for hyperparameter tuning, optimizing massive chemical structures, and even human-in-the-loop optimization employing images
Expand All @@ -22,19 +25,6 @@
- As the artifact module is tightly linked with Optuna, experiment management can be completed with the Optuna ecosystem alone, simplifying the code base.
Table of Contents
-----------------
- Concepts
- Situations where artifacts are useful
- How Trials and Artifacts are Recorded
- Example: Optimization of Chemical structures
- Conclusion
Concepts
--------
Expand Down Expand Up @@ -98,7 +88,7 @@
Normally, Optuna's optimization history is persisted into some kind of a database via storage objects. Here, let's consider a
method using SQLite, a lightweight RDB management system, as the backend. With SQLite, data is stored in a single file (e.g.,
./sqlite.db). The optimization history comprises what parameters were sampled in each trial, what the evaluation values for those
./example.db). The optimization history comprises what parameters were sampled in each trial, what the evaluation values for those
parameters were, when each trial started and ended, etc. This file is in the SQLite format, and it is not suitable for storing
large data. Writing large data entries may cause performance degradation. Note that SQLite is not suitable for distributed parallel
optimization. If you want to perform that, please use MySQL as we will explain later, or JournalStorage
Expand Down Expand Up @@ -140,7 +130,7 @@ def objective(trial: optuna.Trial) -> float:
return ...
study = optuna.create_study(study_name="test_study", storage="sqlite:///sqlite.db")
study = optuna.create_study(study_name="test_study", storage="sqlite:///example.db")
study.optimize(objective, n_trials=100)
# Loading and displaying artifacts associated with the best trial.
best_artifact_id = study.best_trial.user_attrs.get("artifact_id")
Expand Down Expand Up @@ -360,7 +350,11 @@ def __call__(self, trial: Trial) -> float:


def main():
study = create_study(study_name="test_study", storage="sqlite:///sqlite.db")
study = create_study(
study_name="test_study",
storage="sqlite:///example.db",
load_if_exists=True,
)

slab, E_slab = create_slab()
study.set_user_attr("slab", atoms_to_json(slab))
Expand Down

0 comments on commit 565210f

Please sign in to comment.