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

Fix model loading with OptimizerWrapper #430

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

hasan-yaman
Copy link
Contributor

Problem:

  • 1f2a9dc tries to load optimizer and LR scheduler. With this change model saved on the previous versions cannot be loaded with the latest version.

Minimum reproducible example:

# git checkout bb984031fef4a9cc92a321aa8ceae3c0bbb64419
from d3rlpy.algos import DiscreteBCConfig
from d3rlpy.datasets import get_cartpole

dataset, _ = get_cartpole()

model = DiscreteBCConfig().create()

model.fit(
    dataset=dataset,
    n_steps_per_epoch=100,
    n_steps=300
)

model.save("bc.d3")

then try to load model

# git checkout 1f2a9dc8ec95a8b295b68497ea290cc00c362b05
# or to the latest commit git checkout 5400c22d812b2dab9ae66b2def28e5b135c354fd
from d3rlpy import load_learnable

model = load_learnable("bc.d3")

It throws KeyError: 'optim'

Copy link
Owner

@takuseno takuseno left a comment

Choose a reason for hiding this comment

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

LGTM. That's a reasonable solution. Thank you for your contribution!

@takuseno takuseno merged commit e660d23 into takuseno:master Nov 6, 2024
4 checks passed
@hasan-yaman hasan-yaman deleted the fix-loading branch November 6, 2024 13:57
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.

2 participants