Skip to content

Commit

Permalink
Change default KerasAutoEncoder kind to hourglass
Browse files Browse the repository at this point in the history
Also replaced all examples and tests which used feedforward_model
(previously feedforward_symetric) to feedforward_hourglass.
  • Loading branch information
Erik Parmann authored and epa095 committed Feb 25, 2019
1 parent 30f4579 commit cbfefe2
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion examples/Gordo-Workflow-High-Level.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
" steps:\n",
" - sklearn.preprocessing.data.MinMaxScaler\n",
" - gordo_components.model.models.KerasAutoEncoder:\n",
" kind: feedforward_model\n",
" kind: feedforward_hourglass\n",
"\"\"\""
]
},
Expand Down
2 changes: 1 addition & 1 deletion examples/Gordo-Workflow-Semi-Low-Level.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
" steps:\n",
" - sklearn.preprocessing.data.MinMaxScaler\n",
" - gordo_components.model.models.KerasAutoEncoder:\n",
" kind: feedforward_model\n",
" kind: feedforward_hourglass\n",
" \"\"\"\n",
")\n",
"pipe = serializer.pipeline_from_definition(config)\n",
Expand Down
2 changes: 1 addition & 1 deletion gordo_components/builder/build_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def build_model(model_config: dict, data_config: dict, metadata: dict):
model_config: dict - mapping of Model to initialize and any additional
kwargs which are to be used in it's initialization
Example: {'type': 'KerasAutoEncoder',
'kind': 'feedforward_model'}
'kind': 'feedforward_hourglass'}
data_config: dict - mapping of the Dataset to initialize, following the
same logic as model_config
metadata: dict - mapping of arbitrary metadata data
Expand Down
3 changes: 2 additions & 1 deletion gordo_components/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def gordo():


DEFAULT_MODEL_CONFIG = (
"{'gordo_components.model.models.KerasAutoEncoder': {'kind': 'feedforward_model'}}"
"{'gordo_components.model.models.KerasAutoEncoder': {'kind': "
"'feedforward_hourglass'}} "
)


Expand Down
2 changes: 1 addition & 1 deletion gordo_components/serializer/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def dump(obj: object, dest_dir: str, metadata: dict = None):
... # PCA is picklable
... ('pca', PCA(3)),
... # KerasAutoEncoder implements both `save_to_dir` and `load_from_dir`
... ('model', KerasAutoEncoder(kind='feedforward_model'))])
... ('model', KerasAutoEncoder(kind='feedforward_hourglass'))])
>>> with TemporaryDirectory() as tmp:
... serializer.dump(obj=pipe, dest_dir=tmp)
... pipe_clone = serializer.load(source_dir=tmp)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_output_dir(self):

model_config = {
"gordo_components.model.models.KerasAutoEncoder": {
"kind": "feedforward_model"
"kind": "feedforward_hourglass"
}
}
data_config = {"type": "RandomDataset"}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_build_env_args(self):

model_config = {
"gordo_components.model.models.KerasAutoEncoder": {
"kind": "feedforward_model"
"kind": "feedforward_hourglass"
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/test_gordo_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _build_model(target_dir):
steps:
- sklearn.preprocessing.data.MinMaxScaler
- gordo_components.model.models.KerasAutoEncoder:
kind: feedforward_model
kind: feedforward_hourglass
memory:
""",
Loader=ruamel.yaml.Loader,
Expand Down
8 changes: 4 additions & 4 deletions tests/test_serializer_from_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def setUp(self):
n_jobs: 1
transformer_weights:
- gordo_components.model.models.KerasAutoEncoder:
kind: feedforward_model
kind: feedforward_hourglass
""",
# This has only some named parameters included
"""
Expand All @@ -85,7 +85,7 @@ def setUp(self):
- sklearn.decomposition.truncated_svd.TruncatedSVD:
n_components: 2
- gordo_components.model.models.KerasAutoEncoder:
kind: feedforward_model
kind: feedforward_hourglass
""",
# Define pipeline memory with something other than None w/o metadata
"""
Expand Down Expand Up @@ -130,7 +130,7 @@ def setUp(self):
n_jobs: 1
transformer_weights:
- gordo_components.model.models.KerasAutoEncoder:
kind: feedforward_model
kind: feedforward_hourglass
""",
]

Expand Down Expand Up @@ -193,4 +193,4 @@ def _verify_pipe(self, pipe):
# STEP 4 TEST: Finally, the last step should be a KerasModel
step4 = pipe.steps[3][1]
self.assertIsInstance(step4, KerasAutoEncoder)
self.assertTrue(step4.kind, "feedforward_model")
self.assertTrue(step4.kind, "feedforward_hourglass")
14 changes: 7 additions & 7 deletions tests/test_serializer_into_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def setUp(self):
]
),
),
("ae", KerasAutoEncoder(kind="feedforward_model")),
("ae", KerasAutoEncoder(kind="feedforward_hourglass")),
]
),
# MinMax initialized (wrongly) with a list
Expand All @@ -67,7 +67,7 @@ def setUp(self):
]
),
),
("ae", KerasAutoEncoder(kind="feedforward_model")),
("ae", KerasAutoEncoder(kind="feedforward_hourglass")),
]
),
# MinMax initialized with tuple
Expand All @@ -91,7 +91,7 @@ def setUp(self):
]
),
),
("ae", KerasAutoEncoder(kind="feedforward_model")),
("ae", KerasAutoEncoder(kind="feedforward_hourglass")),
]
),
# First pipeline without explicit steps param, other with.
Expand All @@ -115,7 +115,7 @@ def setUp(self):
]
),
),
("ae", KerasAutoEncoder(kind="feedforward_model")),
("ae", KerasAutoEncoder(kind="feedforward_hourglass")),
]
),
]
Expand Down Expand Up @@ -161,7 +161,7 @@ def test_pipeline_into_definition(self):
n_jobs:
transformer_weights:
- gordo_components.model.models.KerasAutoEncoder:
kind: feedforward_model
kind: feedforward_hourglass
memory:
""".rstrip()
.strip()
Expand Down Expand Up @@ -214,7 +214,7 @@ def test_into_from(self):
"step_2",
FunctionTransformer(func=multiply_by, kw_args={"factor": 1}),
),
("step_3", KerasAutoEncoder(kind="feedforward_model")),
("step_3", KerasAutoEncoder(kind="feedforward_hourglass")),
]
)

Expand Down Expand Up @@ -269,7 +269,7 @@ def test_from_into(self):
n_jobs: 1
transformer_weights:
- gordo_components.model.models.KerasAutoEncoder:
kind: feedforward_model
kind: feedforward_hourglass
memory:
"""
definition = ruamel.yaml.load(definition, Loader=ruamel.yaml.Loader)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_serializer_load_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_pipeline_serialization(self):
]
),
),
("ae", KerasAutoEncoder(kind="feedforward_model")),
("ae", KerasAutoEncoder(kind="feedforward_hourglass")),
]
)

Expand Down Expand Up @@ -162,7 +162,7 @@ def test_pipeline_serialization(self):

def test_dump_load_keras_directly(self):

model = KerasAutoEncoder(kind="feedforward_model")
model = KerasAutoEncoder(kind="feedforward_hourglass")

X = np.random.random(size=100).reshape(10, 10)
model.fit(X.copy(), X.copy())
Expand Down

0 comments on commit cbfefe2

Please sign in to comment.