From f9d943c4ee3613401d26bd7baa609a1f58ca3a39 Mon Sep 17 00:00:00 2001 From: Felix Kleinert <f.kleinert@fz-juelich.de> Date: Fri, 2 Jul 2021 08:12:02 +0200 Subject: [PATCH] update IntelliO3 model --- mlair/model_modules/abstract_model_class.py | 2 ++ mlair/model_modules/model_class.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mlair/model_modules/abstract_model_class.py b/mlair/model_modules/abstract_model_class.py index 989f4578..8af85892 100644 --- a/mlair/model_modules/abstract_model_class.py +++ b/mlair/model_modules/abstract_model_class.py @@ -6,6 +6,7 @@ import keras import tensorflow as tf from mlair.helpers import remove_items +from keras import backend as K class AbstractModelClass(ABC): @@ -36,6 +37,7 @@ class AbstractModelClass(ABC): self.__compile_options_is_set = False self._input_shape = input_shape self._output_shape = self.__extract_from_tuple(output_shape) + self.avail_gpus = K.tensorflow_backend._get_available_gpus() def __getattr__(self, name: str) -> Any: """ diff --git a/mlair/model_modules/model_class.py b/mlair/model_modules/model_class.py index b39e97df..004fd217 100644 --- a/mlair/model_modules/model_class.py +++ b/mlair/model_modules/model_class.py @@ -350,7 +350,7 @@ class MyTowerModel(AbstractModelClass): self.compile_options = {"loss": [keras.losses.mean_squared_error], "metrics": ["mse"]} -class IntelliO3_ts_architecture(AbstractModelClass): +class IntelliO3TsArchitecture(AbstractModelClass): def __init__(self, input_shape: list, output_shape: list): """ @@ -454,7 +454,11 @@ class IntelliO3_ts_architecture(AbstractModelClass): kernel_regularizer=self.regularizer ) - self.model = keras.Model(inputs=X_input, outputs=[out_minor1, out_main]) + model = keras.Model(inputs=X_input, outputs=[out_minor1, out_main]) + if self.avail_gpus == 0: + self.model = model + else: + self.model = keras.utils.multi_gpu_model(model, self.avail_gpus) def set_compile_options(self): self.optimizer = keras.optimizers.SGD(lr=self.initial_lr, momentum=0.9) -- GitLab