Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass copy of config to emloop training #37

Merged
merged 3 commits into from
Nov 5, 2018
Merged

Pass copy of config to emloop training #37

merged 3 commits into from
Nov 5, 2018

Conversation

gdynusa
Copy link
Contributor

@gdynusa gdynusa commented Nov 2, 2018

closes #31

@gdynusa gdynusa requested a review from FloopCZ November 2, 2018 20:00
Copy link
Contributor

@FloopCZ FloopCZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @gdynusa! I am glad you reproduced the issue, good job. :-)

def __init__(self, config_str: str):
super().__init__(config_str)
config = yaml.load(config_str)
self.train = {'a': 'b'}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We assume that the data are always batched, so 'a': ['b'] is preferred here.

@@ -239,3 +278,23 @@ def test_create_model(tmpdir):
restored_model = create_model(config=new_config, output_dir=tmpdir + '_restored', dataset=dataset,
restore_from=tmpdir)
assert isinstance(restored_model, DummyModelWithKwargs2)


def test_config_file_is_unchanged(tmpdir):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add link to the issue for which this is regression test.


assert config['dataset']['dataset_config'] == ['a', 'b', 'c']
assert config['hooks'][0]['emloop.tests.cli.common_test.DummyConfigHook']['variables'] == ['a', 'b']
assert config['model']['architecture']['model_config'] == ['a', 'b', 'c', 'd']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just pass deepcopy() to the run() function and test that the entire dict has not changed.

dataset_config[1], dataset_config[0], dataset_config[2]

def train_stream(self):
yield self.train
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can yield the dict directly, no private variable needed.


def _configure_dataset(self, dataset_config: List[str], **kwargs):
dataset_config[0], dataset_config[1], dataset_config[2] = \
dataset_config[1], dataset_config[0], dataset_config[2]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also change those directly in the constructor.

self.change_config(**kwargs)

def change_config(self, variables: List[str], **kwargs):
variables[0], variables[1] = variables[1], variables[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest moving this to the constructor. Also the self.kwargs are never used, no need to save them.

class DummyConfigModel(DummyModel):
"""Dummy model which changes config."""
def __init__(self, **kwargs):
self.kwargs = kwargs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never used, just remove this variable


def _create_model(self, architecture: Mapping, **kwargs):
config = architecture['model_config']
config[0], config[1], config[2], config[3] = config[1], config[0], config[3], config[2]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change those directly in the constructor.

Copy link
Contributor

@FloopCZ FloopCZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @gdynusa.

@FloopCZ FloopCZ merged commit 1f61a52 into dev Nov 5, 2018
@FloopCZ FloopCZ deleted the common-test branch November 5, 2018 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Config YAML in log dir differs
2 participants