From d3166768f57ebaf8bf20db8786cd6dd14212576f Mon Sep 17 00:00:00 2001 From: Shengsheng Huang Date: Tue, 31 May 2022 10:25:12 +0000 Subject: [PATCH 1/2] add parallel search support for sequential API --- .../bigdl/nano/automl/tf/keras/Sequential.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/python/nano/src/bigdl/nano/automl/tf/keras/Sequential.py b/python/nano/src/bigdl/nano/automl/tf/keras/Sequential.py index 069ebf8378b..5791e8aa551 100644 --- a/python/nano/src/bigdl/nano/automl/tf/keras/Sequential.py +++ b/python/nano/src/bigdl/nano/automl/tf/keras/Sequential.py @@ -63,3 +63,22 @@ def _model_init_args(self, trial): newl = copy.deepcopy(layer) instantiated_layers.append(newl) return {'layers': instantiated_layers, 'name': self.name_} + + def _get_model_init_args_func_kwargs(self): + """Return the kwargs of _model_init_args_func except trial.""" + return { + 'lazylayers': self.lazylayers_, + 'name': self.name_, + 'backend': self.backend + } + + @staticmethod + def _model_init_args_func(trial, lazylayers, name, backend): + instantiated_layers = [] + for layer in lazylayers: + if isinstance(layer, AutoObject): + newl = backend.instantiate(trial, layer) + else: + newl = copy.deepcopy(layer) + instantiated_layers.append(newl) + return {'layers': instantiated_layers, 'name': name} \ No newline at end of file From ace04ba83aa641531e535ec07d641639b3b05766 Mon Sep 17 00:00:00 2001 From: Shengsheng Huang Date: Tue, 31 May 2022 10:27:33 +0000 Subject: [PATCH 2/2] fix code style --- python/nano/src/bigdl/nano/automl/tf/keras/Sequential.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/nano/src/bigdl/nano/automl/tf/keras/Sequential.py b/python/nano/src/bigdl/nano/automl/tf/keras/Sequential.py index 5791e8aa551..0f1f665768c 100644 --- a/python/nano/src/bigdl/nano/automl/tf/keras/Sequential.py +++ b/python/nano/src/bigdl/nano/automl/tf/keras/Sequential.py @@ -81,4 +81,4 @@ def _model_init_args_func(trial, lazylayers, name, backend): else: newl = copy.deepcopy(layer) instantiated_layers.append(newl) - return {'layers': instantiated_layers, 'name': name} \ No newline at end of file + return {'layers': instantiated_layers, 'name': name}