Ignite: save the best score in engine.state?

Created on 18 Sep 2019  路  2Comments  路  Source: pytorch/ignite

Hi, I want to print the best score at the end of training.

ModelCheckpoint handler can save the best model with the best score,
however, I just want to print the best score at the end of training.

Is it possible to save the best score till the end of training?

question

Most helpful comment

@Soo95 there is nothing done for this today. I would say this can be done manually when run evaluators.


@trainer.on(Events.STARTED)
def init_best_score(engine):
    engine.state.best_score = 0.0

@trainer.on(Events.EPOCH_COMPLETED)
def run_evaluation(engine):
     res = evaluator.run(val_loader)
     trainer.state.best_score = max(trainer.state.best_score, res['your_metric'])


res = trainer.run(train_loader, 10)
print("Best score is : ", res.best_score)

HTH

All 2 comments

@Soo95 there is nothing done for this today. I would say this can be done manually when run evaluators.


@trainer.on(Events.STARTED)
def init_best_score(engine):
    engine.state.best_score = 0.0

@trainer.on(Events.EPOCH_COMPLETED)
def run_evaluation(engine):
     res = evaluator.run(val_loader)
     trainer.state.best_score = max(trainer.state.best_score, res['your_metric'])


res = trainer.run(train_loader, 10)
print("Best score is : ", res.best_score)

HTH

@vfdev-5
I always thank for your kind replies!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vfdev-5 picture vfdev-5  路  3Comments

vfdev-5 picture vfdev-5  路  3Comments

jphdotam picture jphdotam  路  4Comments

karfly picture karfly  路  4Comments

CreateRandom picture CreateRandom  路  3Comments