[tune] Save and Restore for bayesopt (#5623)

This commit is contained in:
Hersh Godse
2019-09-10 13:11:59 -07:00
committed by Richard Liaw
parent 4d16677a68
commit 336aef1774
3 changed files with 79 additions and 1 deletions
+11
View File
@@ -4,6 +4,7 @@ from __future__ import print_function
import copy
import logging
import pickle
try: # Python 3 only -- needed for lint test.
import bayes_opt as byo
except ImportError:
@@ -111,3 +112,13 @@ class BayesOptSearch(SuggestionAlgorithm):
def _num_live_trials(self):
return len(self._live_trial_mapping)
def save(self, checkpoint_dir):
trials_object = self.optimizer
with open(checkpoint_dir, "wb") as output:
pickle.dump(trials_object, output)
def restore(self, checkpoint_dir):
with open(checkpoint_dir, "rb") as input:
trials_object = pickle.load(input)
self.optimizer = trials_object
+11
View File
@@ -3,6 +3,7 @@ from __future__ import division
from __future__ import print_function
import logging
import pickle
try:
import skopt as sko
except ImportError:
@@ -157,3 +158,13 @@ class SkOptSearch(SuggestionAlgorithm):
def _num_live_trials(self):
return len(self._live_trial_mapping)
def save(self, checkpoint_dir):
trials_object = self._skopt_opt
with open(checkpoint_dir, "wb") as output:
pickle.dump(trials_object, output)
def restore(self, checkpoint_dir):
with open(checkpoint_dir, "rb") as input:
trials_object = pickle.load(input)
self._skopt_opt = trials_object