Hi again. I apologize in advance but I’ve tried solving this for 2 hours now. I’m not sure what I did but suddenly the attaching doesn’t work anymore. It doesn’t recognize “mse” :

Which  is weird because it should since below is what I call in train():
model = get_network(cfg)

    to_save = {
        "model": model,
    }

    def score_function(engine):
        return -evaluator.state.metrics["mse"]

    handler = ModelCheckpoint(
        "models/", "checkpoint", score_function=score_function, n_saved=5
    )

    # Data Loaders
    train_loader, val_loader = get_dataloaders(cfg, num_workers=cfg.data_loader_workers)

    # Your training loop
    trainer = create_training_loop(model, cfg, "trainer", device=device)

    # Your evaluation loop
    evaluator = create_evaluation_loop(model, cfg, "evaluator", device=device)


    trainer.add_event_handler(Events.EPOCH_COMPLETED(every=10), handler, {"mlp": model})

And then here is a screenshot of  the actual code of create_evaluation_loop(), as well as the terminal where I use pdb to show that despite the for loop  where I attach running,  afterwards the engine still doesn’t have anything in :  engine.state.metrics …
pdbscreen2144×1268 776 KB