Skip to content

Duplicate epochs when calling .fit() twice #5007

@carmocca

Description

@carmocca

🐛 Bug

To Reproduce

def test_bug(tmpdir):
    epochs = []
    
    class TestModel(BoringModel):
        def on_epoch_end(self):
            epochs.append(self.current_epoch)
    
    trainer = Trainer(
        max_epochs=2,
        limit_train_batches=1,
        limit_val_batches=1,
        default_root_dir=tmpdir,
        checkpoint_callback=False,
        logger=False,
        weights_summary=None,
        progress_bar_refresh_rate=0,
    )
    trainer.fit(TestModel())
    trainer.max_epochs=4
    trainer.fit(TestModel())

    assert epochs == list(range(4))
    # AssertionError [0, 1, 1, 2, 3] != [0, 1, 2, 3]

Expected behavior

Assertion does not fail

Environment

Current master

cc @tchaton @Borda

Metadata

Metadata

Assignees

Labels

breaking changeIncludes a breaking changebugSomething isn't workinghelp wantedOpen to be worked onpriority: 0High priority task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions