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

experiment results loader #5

Open
Ootzk opened this issue Oct 4, 2021 · 1 comment
Open

experiment results loader #5

Ootzk opened this issue Oct 4, 2021 · 1 comment
Assignees
Labels
analysis Analysis of result enhancement New feature or request

Comments

@Ootzk
Copy link
Owner

Ootzk commented Oct 4, 2021

at analyze.py

@Ootzk Ootzk added enhancement New feature or request analysis Analysis of result labels Oct 4, 2021
@Ootzk Ootzk self-assigned this Oct 4, 2021
@Ootzk
Copy link
Owner Author

Ootzk commented Oct 4, 2021

def load_pretrained_model(ID: int, checkpoint: int, verbose: bool):
    experiment_dir = f'experiments/{ID}'
    with open(f'{experiment_dir}/config.json', 'r') as exp_config_file:
        exp_config = json.load(exp_config_file)
        
    if verbose:
        print(f'experiment configuration: ')
        pprint.pprint(exp_config)
        
    model = load_model(exp_config)
    for candidate in os.listdir(f'{experiment_dir}/checkpoints/'):
        if candidate.startswith(f'checkpoint_{checkpoint}_'):
            model.load_state_dict(torch.load(f'{experiment_dir}/checkpoints/{candidate}')['model'])
            if verbose:
                print(f'checkpoint: epoch @ {checkpoint} loaded successfully! return pretrained model and configuration.')
            return model, exp_config
        
    if verbose:
        print(f'checkpoint: epoch @ {checkpoint} not searched; just return skeleton and configuration.')
        return model, exp_config

reference model loader

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analysis Analysis of result enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant