示例#1
0
def sacred_run(command, name='train', default_configs_root='default_configs'):

    ex = Experiment(name)

    def default_config(config, command_name, logger):
        default_config = {}

        components = ['datasets', 'modules', 'optimizers']

        for comp in components:
            file_name = '{}.yaml'.format(comp)
            default_file_path = join(default_configs_root, file_name)
            default_config[comp] = get_component_configs(config, comp, default_file_path)

        # loading experiment default configs
        fn = join(default_configs_root, 'experiment.yaml')
        default_experiment_args = load_config_file(fn)
        default_args = default_experiment_args[config['experiment']['_name']]
        default_config['experiment'] = default_args

        return default_config

    ex.config_hook(default_config)
    ex.main(command)
    ex.run_commandline()
def sacred_run(command, name='train', default_configs_root='default_configs'):

    ex = Experiment(name)

    def default_config(config, command_name, logger):
        default_config = {}
        
        # loading modules default config
        fn = join(default_configs_root, 'modules.yaml')
        default_modules_args = load_config_file(fn)
        default_config['modules'] = {}
        for module, module_config in config['modules'].items():
            default_args = default_modules_args[module_config['_name']]
            default_config['modules'][module] = default_args

        # loading datasets default config
        fn = join(default_configs_root, 'datasets.yaml')
        default_datasets_args = load_config_file(fn)
        default_config['datasets'] = {}
        for dataset, dataset_config in config['datasets'].items():
            default_args = default_datasets_args[dataset_config['_name']]
            default_config['datasets'][dataset] = default_args

        # loading experiment default configs
        fn = join(default_configs_root, 'experiment.yaml')
        default_experiment_args = load_config_file(fn)
        default_args = default_experiment_args[config['experiment']['_name']]
        default_config['experiment'] = default_args

        return default_config

    ex.config_hook(default_config)
    ex.main(command)
    ex.run_commandline()
示例#3
0
def wrap_with_sacred(command, ex_hook):
    ex = Experiment()
    ex_hook(ex)
    ex.config_hook(load_default_config)
    ex.main(command)
    ex.run_commandline()