Skip to content

Instantly share code, notes, and snippets.

@aisu-wata0
aisu-wata0 / ParamRepeatPruner.py
Last active October 25, 2022 15:40
For optuna/optuna#2021. Class that prunes trials with the same parameters as past trials. You also can allow repeats if you want, and get the average of these past trials instead of pruning.
import optuna
from optuna.trial import TrialState
import numpy as np
from typing import Dict, List, Optional
from collections import defaultdict
class ParamRepeatPruner:
"""Prunes reapeated trials, which means trials with the same paramters won't waste time/resources."""
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->