Skip to content
Snippets Groups Projects
Commit 9c7aefb7 authored by Felix Kleinert's avatar Felix Kleinert
Browse files

update doc strings

parent 4e243772
No related branches found
No related tags found
3 merge requests!125Release v0.10.0,!124Update Master to new version v0.10.0,!92introduce 'compile_options' in model_class which combines all allowed args of...
Pipeline #36728 failed
...@@ -107,8 +107,44 @@ class AbstractModelClass(ABC): ...@@ -107,8 +107,44 @@ class AbstractModelClass(ABC):
@property @property
def compile_options(self) -> Callable: def compile_options(self) -> Callable:
""" """
The compile options property allows the user to use all keras.compile() arguments which are not already covered The compile options property allows the user to use all keras.compile() arguments. They can ether be passed as
by __loss and optimizer dictionary (1), as attribute, with compile_options=None (2) or as mixture of both of them (3).
The method will raise an Error when the same parameter is set differently.
Example (1)
.. code-block:: python
def set_compile_options(self):
self.compile_options = {"optimizer": keras.optimizers.SGD(),
"loss": keras.losses.mean_squared_error,
"metrics": ["mse", "mae"]}
Example (2)
.. code-block:: python
def set_compile_options(self):
self.optimizer = keras.optimizers.SGD()
self.loss = keras.losses.mean_squared_error
self.metrics = ["mse", "mae"]
self.compile_options = None # make sure to use this line
Example (3)
Correct:
.. code-block:: python
def set_compile_options(self):
self.optimizer = keras.optimizers.SGD()
self.loss = keras.losses.mean_squared_error
self.compile_options = {"metrics": ["mse", "mae"]}
Incorrect: (Will raise an error)
.. code-block:: python
def set_compile_options(self):
self.optimizer = keras.optimizers.SGD()
self.loss = keras.losses.mean_squared_error
self.compile_options = {"optimizer" = keras.optimizers.Adam(), "metrics": ["mse", "mae"]}
Note: As long as the attribute and the dict value have exactly the same values, the setter method will not raise
an error
:return: :return:
""" """
return self.__compile_options return self.__compile_options
...@@ -135,15 +171,6 @@ class AbstractModelClass(ABC): ...@@ -135,15 +171,6 @@ class AbstractModelClass(ABC):
raise SyntaxError( raise SyntaxError(
f"Got different values for same argument: self.{allow_k}={new_v_attr} and '{allow_k}': {new_v_dic}") f"Got different values for same argument: self.{allow_k}={new_v_attr} and '{allow_k}': {new_v_dic}")
# if not isinstance(value, dict):
# raise TypeError(f"`value' has to be a dictionary. But it is {type(value)}")
# for new_k, new_v in value.items():
# if new_k in self.__allowed_compile_options.keys():
# self.__compile_options[new_k] = new_v
# else:
# logging.warning(
# f"`{new_k}' is not a valid additional compile option. Will be ignored in keras.compile()")
def get_settings(self) -> Dict: def get_settings(self) -> Dict:
""" """
Get all class attributes that are not protected in the AbstractModelClass as dictionary. Get all class attributes that are not protected in the AbstractModelClass as dictionary.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment