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

Carry over optimiser state in update() methods #86

Merged
merged 13 commits into from
Feb 23, 2021
Merged

Conversation

ablaom
Copy link
Collaborator

@ablaom ablaom commented Feb 22, 2021

This PR corrects an issue whereby optimiser "state" (eg, the momentum) is not carried over in a warm-restart. For example, the following test (added in this PR) now passes:

            using MLJBase, MLJFlux
            X, y = make_regression()
            model = NeuralNetworkRegressor() 
            
             model.epochs = 1
             mach = machine(model, $X, $y);

             # two epochs in stages:
             Random.seed!(123)
             fit!(mach, verbosity=0);
             model.epochs = model.epochs + 1
             fit!(mach, verbosity=0);
             l1 = MLJBase.report(mach).training_losses[end]

             # two epochs in one go:
             Random.seed!(123)
             fit!(mach, verbosity=1, force=true)
             l2 = MLJBase.report(mach).training_losses[end]

             @test l1  l2

@ablaom ablaom marked this pull request as draft February 22, 2021 21:54
@ablaom ablaom marked this pull request as ready for review February 23, 2021 05:28
@ablaom
Copy link
Collaborator Author

ablaom commented Feb 23, 2021

The tests referred to in the opening post pass on the CPU. However, they do not pass on the GPU for reasons I don't understand at this time.

Since the current PR does fix a bug, I am going to merge this and postpone the other half of the bug to a new issue.

I've marked the failing tests (which do not previously exist) as broken.

@ablaom ablaom merged commit 763885a into dev Feb 23, 2021
@ablaom ablaom deleted the optimisers-and-update branch February 23, 2021 05:30
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.

None yet

1 participant