A context where the model is temporarily changed to eval mode, and restored to previous mode afterwards. Args: model: a torch Module
(model)
| 1439 | |
| 1440 | @contextmanager |
| 1441 | def inference_context(model): |
| 1442 | """ |
| 1443 | A context where the model is temporarily changed to eval mode, |
| 1444 | and restored to previous mode afterwards. |
| 1445 | |
| 1446 | Args: |
| 1447 | model: a torch Module |
| 1448 | """ |
| 1449 | training_mode = model.training |
| 1450 | model.eval() |
| 1451 | yield |
| 1452 | model.train(training_mode) |
| 1453 | |
| 1454 | |
| 1455 | def print_csv_format(results, logger): |
no test coverage detected