admin管理员组文章数量:1242701
I am using Optuna to optimize the parameters of a non-ML task. Now, each trial consists in processing several files in sequence, each of which gets a score. The scores are summed cumulatively in order to allow Optuna to prune unfavorable trials, and the final sum of all scores is reported.
In order to optimize pruning, I want to have the highest variance files be processed first, as those are the most relevant to determine whether a run should be stopped or not. However, in order to know which files have the highest variance, I first must run some trials without any pruning. Once I have done that, I can determine from the results the optimal order in which to process the files.
However, there is no reason to discard the previous results. So I have written a small script that extracts the existing scores, including the intermediate steps, and re-arranges them as if the best optimal file processing order had always been used. I'd now like to create a new study with some trials that report my newly "re-arranged" scores.
However, I can't figure out a way to also pass the original parameter values to the new trials. With my current code, I get a study that reports the correct score, but doesn't show any parameter at all (since I'm not currently copying them). Is there a way to do so?
Below is an excerpt of my script to give an idea of what I'm looking for.
new_study = optuna.create_study(
storage=new_storage,
study_name=args.study_name,
direction="maximize")
for i, trial in enumerate(completed_trials):
new_trial = new_study.ask()
# How to actually copy these? What else should be copied?
#
# new_trial.distributions = cp.deepcopy(trial.distributions)
# new_trial.params = cp.deepcopy(trial.params)
new_trial_score = cum_reordered_scores[i]
for i in range(len(new_trial_score)):
new_trial.report(new_trial_score[i], i)
new_study.tell(new_trial, new_trial_score[-1])
本文标签: pythonCopy Optuna study while slightly altering trial scoresStack Overflow
版权声明:本文标题:python - Copy Optuna study while slightly altering trial scores - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740143631a2231367.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论