Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Optunaによる多目的最適化

 Optunaによる多目的最適化

Optuna Meetup #1 での発表資料です。

4873af9fdcd763a56f8f3fa801f76798?s=128

Yoshihiko Ozaki

June 29, 2021
Tweet

Transcript

  1. OptunaʹΑΔଟ໨త࠷దԽ Optuna Meetup #1 2021/06/26 ඌ࡚ Յ඙ 1

  2. ඌ࡚ Յ඙ • ॴଐ • άϦʔגࣜձࣾʗ࢈ۀٕज़૯߹ݚڀॴਓ޻஌ೳηϯλʔ • ࠷ۙͷݚڀ • Ozaki,

    Y., Tanigaki, Y., Watanabe, S., & Onishi, M. (2020). Multiobjective tree-structured parzen estimator for computationally expensive optimization problems. In Proceedings of the 2020 Genetic and Evolutionary Computation Conference (pp. 533-541). • Ozaki, Y., Suzuki, Y., Hawai, T., Saito, K., Onishi, M., & Ono, K. (2020). Automated crystal structure analysis based on blackbox optimisation. npj Computational Materials, 6(1), 1-7. • ඌ࡚Յ඙, ໺ଜক׮, & େ੢ਖ਼ً. (2020). ػցֶशʹ͓͚ΔϋΠύύϥϝʔλ࠷దԽख๏: ֓ཁͱಛ ௃. ిࢠ৘ใ௨৴ֶձ࿦จࢽ D, 103(9), 615-631. 2
  3. ໨࣍ • ͸͡Ίʹɿଟ໨త࠷దԽ • Optunaɿଟ໨త࠷దԽख๏ • Optunaɿଟ໨త࠷దԽؔ࿈ػೳ • ·ͱΊ 3

  4. ͸͡Ίʹɿଟ໨త࠷దԽ 4

  5. ଟ໨త࠷దԽ • ໨త࠷దԽ໰୊ • ಉ࣌ʹ࠷దԽ͞ΕΔ ݸͷ໨తؔ਺͕ଘࡏ͢Δ໰୊ • ྫɿ੒ాۭߓ 㱺 ϑϥϯΫϑϧτؒͷҠಈϓϥϯ

    • ✔ Ҡಈ࣌ؒͷ࠷খԽ 㱻 ✔ අ༻ͷ࠷খԽʢ2ͭͷ໨త͸τϨʔυΦϑͷؔ܎ʣ m m 5
  6. ଟ໨త࠷దԽ • ໨త࠷దԽ໰୊ • ಉ࣌ʹ࠷దԽ͞ΕΔ ݸͷ໨తؔ਺͕ଘࡏ͢Δ໰୊ m m ໨తۭؒ (f1

    (x), f2 (x)) ୈ2໨తɿf2 (x) ୈ1໨తɿf1 (x) 2໨త࠷খԽ໰୊ Minimize/Maximize subject to ɿ ൪໨ͷ໨తؔ਺ ɿܾఆม਺ ɿ࣮ߦՄೳྖҬ f1 (x), f2 (x), …, fm (x) x ∈ X fi (x) i x X ୳ࡧۭؒ X x1 x2 ࣸ૾ 6
  7. ଟ໨త࠷దԽ • ଟ໨త࠷దԽ໰୊Ͱ͸ɼ୯Ұͷ࠷దղ͸Ұൠʹଘࡏ͠ͳ͍ • ଞͷ೚ҙͷղʹ༏ӽ͞Εͳ͍શͯͷղͷू߹ΛύϨʔτηοτͱݺͼ ύϨʔτηοτͷ໨తۭؒͰͷ૾ΛύϨʔτϑϩϯτͱݺͿ ύϨʔτϑϩϯτ ྉۚ Ҡಈ࣌ؒ 2໨తʢҠಈ࣌ؒɼྉۚʣ࠷খԽ

    ༏ӽؔ܎ • A͸BΛ༏ӽ͢Δ • AͱC͸ൺֱෆՄೳͷؔ܎ ଟ໨త࠷దԽΛղ͘ͱ͸ύϨʔτηοτ ΛٻΊΔʢۙࣅ͢Δʣ͜ͱ 7
  8. Optunaɿଟ໨త࠷దԽख๏ 8

  9. Optunaͱଟ໨త࠷దԽɿػցֶशʹ͓͚ΔԠ༻ • λεΫ • Hyperparameter Optimization • Neural Architecture Search

    • ໨తؔ਺ • Ϟσϧਫ਼౓ • ϞσϧαΠζʢ଎౓ɼফඅిྗʣ https://arxiv.org/abs/2105.01015 9
  10. ଟ໨త࠷దԽख๏ • ݱࡏOptunaͰར༻Մೳͳख๏ • ਐԽܕଟ໨త࠷దԽɿNSGA-II • ଟ໨తϕΠζ࠷దԽɿMOTPEɼqEHVI (integration.botorch) 10

  11. ਐԽܕଟ໨త࠷దԽ • ਐԽܭࢉΛ༻͍Δ͜ͱͰɼύϨʔτϑϩϯτΛۙࣅ͢Δղू߹ΛҰ౓ ͷ࣮ߦͰಉ࣌ʹ֫ಘ͢Δ͜ͱΛ໨తͱͨ͠ख๏ 11

  12. • ղͷ༏ྼΛɼඇ༏ӽϥϯΫʹجͮ͘ऩଋੑɼࠞࡶڑ཭ʹجͮ͘ଟ༷ੑ ͷ؍఺͔Βܾఆ͠ɼ༏ΕͨղΛݩʹ࣍ੈ୅ͷݸମΛੜ੒ NSGA-II (Deb et al., 2002) ඇ༏ӽϥϯΫɿ༏ӽ͞Ε͍ͯͳ͍ղΛRank 1ͱͯͦ͜͠

    ͔Βॱʹऩଋੑʢ༏ӽؔ܎ʣʹԠͯ͡ϥϯΫ͕ܾ·Δ ࠞࡶڑ཭ɿྡΓ߹͏ݸମؒͷϚϯϋολϯڑ཭ͱͯ͠ ܭࢉ͞ΕΔʢ ʣɼ྆୺ʹ͍ͭͯ͸ ͱ໿ଋ͢Δ a + b ∞ 12
  13. Optunaʹ͓͍ͯ NSGA-IIΛ࢖͏ import optuna def objective(trial): x = trial.suggest_float("x", 0,

    5) y = trial.suggest_float("y", 0, 3) v0 = 4 * x ** 2 + 4 * y ** 2 v1 = (x - 5) ** 2 + (y - 5) ** 2 return v0, v1 # objective͸શͯͷ໨తؔ਺஋Λฦ͢ # NSGAIISamplerΛ࢖͏ sampler = optuna.samplers.NSGAIISampler(seed=1234) study = optuna.create_study( sampler=sampler, directions=["minimize", "minimize"] ) study.optimize(objective, n_trials=250) 13
  14. ଟ໨తϕΠζ࠷దԽ • ໨తؔ਺΍୳ࡧۭؒʹ͍ͭͯϕΠζతͳϞσϧΛߏங͠ɼ֫ಘؔ਺ͱ ݺ͹ΕΔج४Λ༻͍ͯ༗๬ͳղΛޮ཰తʹαϯϓϧ͢Δख๏ • ໨తؔ਺ΛϞσϧԽɿຆͲͷଟ໨తϕΠζ࠷దԽख๏ • ୳ࡧۭؒΛϞσϧԽɿMOTPE 14

  15. MOTPE (Ozaki et al., 2020) • Optunaͷ୯໨త࠷దԽʹ͓͚Δඪ४ΞϧΰϦζϜͰ͋ΔTPEΛଟ໨త ࠷దԽʹ֦ுͨ͠΋ͷ • Ϟσϧ͸୳ࡧۭؒ಺ͷ༗๬ɾඇ༗๬ͳղʹ͍ͭͯΧʔωϧີ౓ਪఆ

    ༗๬ ඇ༗๬ ୳ࡧۭؒʹ͓͍ͯରԠ͢Δ༗๬ͳղͷू߹ʹ ͍ͭͯΧʔωϧີ౓ਪఆ ୳ࡧۭؒʹ͓͍ͯରԠ͢Δඇ༗๬ͳղͷू߹ʹ ͍ͭͯΧʔωϧີ౓ਪఆ 15
  16. MOTPE (Ozaki et al., 2020) • ࣍ʹධՁ͢Δղ͸Expected Hypervolume Improvement (EHVI)

    ֫ಘؔ਺ʹΑܾͬͯΊΔ • ू߹ ʹ఺ ΛՃ͑ͨͱ͖ͷϋΠύϘϦϡʔϜ૿Ճྔͷظ଴஋ʹରԠɼ͜ΕΛ࠷େԽ͢Δ Λ࠾༻ • ࣮͸༗๬ɾඇ༗๬ྖҬͷ֬཰ີ౓Λ ɼ ͱͨ͠ͱ͖ɼ ͕੒Γཱͭ EHVIY* (x) := ∫ max(IH (Y* ∪ {y}) − IH (Y*),0)p(y ∣ x)dy Y* y = f(x) x l(x) g(x) argmaxx EHVI(x) = argmaxx l(x)/g(x) Y r • ϋΠύϘϦϡʔϜ͸ ʹଐ͢ΔϕΫτϧͱࢀর఺ ʹғ·ΕͨྖҬ ͷ௒ମੵʢփ৭෦෼ʣ • ύϨʔτϑϩϯτ͸௒ମੵΛ࠷େԽ͢Δ Y r 16
  17. Optunaʹ͓͍ͯ MOTPEΛ࢖͏ ... # MOTPESamplerʹมߋ͢Δ͚ͩ sampler = optuna.samplers.MOTPESampler(seed=1234) study =

    optuna.create_study( sampler=sampler, directions=["minimize", “minimize"] ) study.optimize(objective, n_trials=250) 17
  18. ൺֱɿNSGA-IIͱMOTPE ؆୯ͳ໰୊Ͱ͋Ε͹ͲͪΒͰ΋͙͢ղ͚Δ 18

  19. ൺֱɿNSGA-IIͱMOTPE • ऩଋ͸MOTPEͷํ͕଎͍ ʢAutoML޲͖ʣ ͖ͬ͞ΑΓ೉͍͠໰୊ʢධՁճ਺250ʣ 19

  20. ൺֱɿNSGA-IIͱMOTPE • ऩଋ͸MOTPEͷํ͕଎͍ ʢAutoML޲͖ʣ • MOTPE͸ධՁճ਺ʹݶք͋Γ ʢNSGA-II͸زΒͰ΋ʣ MOTPE͸1000ճͰ15-20෼ఔ౓ɼଞͷଟ໨త ϕΠζ࠷దԽख๏ʢPESMO΍SMS-EGOʣΑΓ ѹ౗తʹ଎͍͕NSGA-IIͱൺ΂Δͱ࿩ʹͳΒͳ͍

    20
  21. ൺֱɿNSGA-IIͱMOTPE • ऩଋ͸MOTPEͷํ͕଎͍ ʢAutoML޲͖ʣ • MOTPE͸ධՁճ਺ʹݶք͋Γ ʢNSGA-II͸زΒͰ΋ʣ • ७ਮͳ཭ࢄ࠷దԽ͸NSGA-II͕ Α͍ʢMOTPE͸ہॴղʹऩଋʣ

    0-1φοϓαοΫʢ2໨త࠷େԽʣ 21
  22. Optunaɿଟ໨త࠷దԽؔ࿈ػೳ 22

  23. ՄࢹԽ • ࢄ෍ਤ • (Parallel coordinate) ... sampler = optuna.samplers.MOTPESampler(seed=1234)

    study = optuna.create_study(sampler=sampler, directions=["minimize", "minimize"]) study.optimize(objective, n_trials=250) # plotlyϕʔεͷՄࢹԽ fig = optuna.visualization.plot_pareto_front(study) fig.show() # matplotlibϕʔεͷՄࢹԽ optuna.visualization.matplotlib.plot_pareto_front( study ) plt.show() 23
  24. ධՁ • ϋΠύϘϦϡʔϜ ... # ϋΠύϘϦϡʔϜܭࢉؔ਺͸͍·ͷͱ͜Ζ։ൃऀ޲͚API
 # কདྷతʹoptuna/_hypervolume/wfg.pyʹҠಈ͞ΕΔ༧ఆ wfg =

    optuna.multi_objective._hypervolume.WFG() reference_point = np.array([3, 5]) trials = study.trials hvs = [] for i in range(1, len(trials) + 1): vector_set = np.array( [t.values for t in trials[:i]] ) hvs.append( wfg.compute(vector_set, reference_point) ) plt.style.use(“ggplot") plt.xlabel("Number of valuations") plt.ylabel("Hypervolume") plt.plot(range(1, len(hvs) + 1), hvs) plt.show() 24
  25. ·ͱΊ • ଟ໨త࠷దԽ͸ύϨʔτ࠷దղͷू߹Λ֫ಘ͢Δ͜ͱ͕໨ඪ • Optuna͸ਐԽܕଟ໨త࠷దԽͱଟ໨తϕΠζ࠷దԽͷ2λΠϓͷख๏Λఏڙ • લऀ͸൚༻తɼNSGA-II͸ͦͷ࠷΋୅දతͳख๏Ͱ໿20೥ؒ΋ͷ࣮੷͕͋Δ • ޙऀ͸AutoML޲͖ɼMOTPE͸ϋΠύύϥϝʔλ࠷దԽख๏TPEͷଟ໨త൛ •

    Optunaͷଟ໨త࠷దԽؔ࿈ػೳΛ঺հ • ଟ໨త࠷దԽ͸ɼ୯໨త࠷దԽʹൺ΂ͯ׆༻ࣄྫ΋։ൃऀ΋গͳ͍ɼࠓճΛ ͖͔͚ͬʹϢʔβ΍։ൃऀ͕૿͑Δͱخ͍͠ 25