-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
nan handling in trial.report and multi-objective study. #2169
Copy link
Copy link
Closed
Labels
bugIssue/PR about behavior that is broken. Not for typos/examples/CI/test but for Optuna itself.Issue/PR about behavior that is broken. Not for typos/examples/CI/test but for Optuna itself.no-staleExempt from stale botExempt from stale botoptuna.studyRelated to the `optuna.study` submodule. This is automatically labeled by github-actions.Related to the `optuna.study` submodule. This is automatically labeled by github-actions.optuna.trialRelated to the `optuna.trial` submodule. This is automatically labeled by github-actions.Related to the `optuna.trial` submodule. This is automatically labeled by github-actions.v3Issue/PR for Optuna version 3.Issue/PR for Optuna version 3.
Description
Expected behavior
trial.report()acceptsnan- Return value of multi-objective study accepts
nan - Multi-objective study mark trials as
FAILEDwhen one or more return values arenan.
Bugs
trial.reportfails when the value isnanwhen combined with MySQL backend.- Multi-objective trial also fails on
reportwithnanvalue when combined with MySQL backend. - Multi-objective study internally depends on
trial.reportand thus error occurs when one or more return value isnan. - With in-memory db, multi-objective study registers trials with
nanreturn value asCOMPLETEDtrial.
Notes
I think whether trial.report should accept nan or not requires discussion.
Environment
- Optuna version: 2.3.0
- Python version: 3.8
- OS: macOS Catalina
- PyMySQL version: 0.10.1
Error messages, stack traces, or logs
(When called trial.report with nan value w/ MySQL backend.)
ProgrammingError: (pymysql.err.ProgrammingError) nan can not be used with MySQL
[SQL: INSERT INTO trial_values (trial_id, step, value) VALUES (%(trial_id)s, %(step)s, %(value)s)]
[parameters: {'trial_id': 34849, 'step': 1, 'value': nan}]
(Background on this error at: http://sqlalche.me/e/13/f405)
Steps to reproduce
trial.report(float(np.nan), 1)
Additional context (optional)
Single-objective study accepts nan as the return value and marks it as failed. This is achieved in the following.
Line 305 in 4b4891d
| if value is not None and math.isnan(value): |
With in-memory db, trial.report accepts nan.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugIssue/PR about behavior that is broken. Not for typos/examples/CI/test but for Optuna itself.Issue/PR about behavior that is broken. Not for typos/examples/CI/test but for Optuna itself.no-staleExempt from stale botExempt from stale botoptuna.studyRelated to the `optuna.study` submodule. This is automatically labeled by github-actions.Related to the `optuna.study` submodule. This is automatically labeled by github-actions.optuna.trialRelated to the `optuna.trial` submodule. This is automatically labeled by github-actions.Related to the `optuna.trial` submodule. This is automatically labeled by github-actions.v3Issue/PR for Optuna version 3.Issue/PR for Optuna version 3.