[tune] Save/Restore for Suggestion Algs (#5719)

This commit is contained in:
Hersh Godse
2019-09-21 11:11:57 -07:00
committed by Richard Liaw
parent 7e214fd95e
commit d17b35494d
6 changed files with 156 additions and 69 deletions
+12
View File
@@ -3,6 +3,7 @@ from __future__ import division
from __future__ import print_function
import logging
import pickle
try:
import nevergrad as ng
except ImportError:
@@ -145,3 +146,14 @@ class NevergradSearch(SuggestionAlgorithm):
def _num_live_trials(self):
return len(self._live_trial_mapping)
def save(self, checkpoint_dir):
trials_object = (self._nevergrad_opt, self._parameters)
with open(checkpoint_dir, "wb") as outputFile:
pickle.dump(trials_object, outputFile)
def restore(self, checkpoint_dir):
with open(checkpoint_dir, "rb") as inputFile:
trials_object = pickle.load(inputFile)
self._nevergrad_opt = trials_object[0]
self._parameters = trials_object[1]