Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MLAir
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esde
machine-learning
MLAir
Commits
9c7aefb7
Commit
9c7aefb7
authored
5 years ago
by
Felix Kleinert
Browse files
Options
Downloads
Patches
Plain Diff
update doc strings
parent
4e243772
No related branches found
No related tags found
3 merge requests
!125
Release v0.10.0
,
!124
Update Master to new version v0.10.0
,
!92
introduce 'compile_options' in model_class which combines all allowed args of...
Pipeline
#36728
failed
5 years ago
Stage: test
Stage: pages
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/model_modules/model_class.py
+38
-11
38 additions, 11 deletions
src/model_modules/model_class.py
with
38 additions
and
11 deletions
src/model_modules/model_class.py
+
38
−
11
View file @
9c7aefb7
...
@@ -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.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment