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

add backbone override to hydra #997

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/fairchem/core/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ def __init__(
# if finetune_config is provided, then attempt to load the model from the given finetune checkpoint
starting_model = None
if finetune_config is not None:
# Make it hard to sneak more fields into finetuneconfig
assert (
len(set(finetune_config.keys()) - {["starting_checkpoint", "override"]})
== 0
)
starting_model: HydraModel = load_model_and_weights_from_checkpoint(
finetune_config["starting_checkpoint"]
)
Expand All @@ -260,6 +265,10 @@ def __init__(
assert isinstance(
starting_model, HydraModel
), "Can only finetune starting from other hydra models!"
# TODO this is a bit hacky to overrride attrs in the backbone
if "overrride" in finetune_config:
for key, value in finetune_config:
setattr(starting_model.backbone, key, value)

if backbone is not None:
backbone = copy.deepcopy(backbone)
Expand Down
Loading