<commit_before>import copy
import numpy as np
import cma
import math
import random
import copy

SIGMA0 = 0.25
EPSILON = 1e-12

# Overwrite the parameters of CMAES
OPTIMIZER_CONFIG = {
    'popsize': 3,
}

# Termination criterion for stopping CMAES
TERM_CRITERION = {
    'generation': 20, # Number of generation to run to
    'fitness': 999, # Threshold fitness to reach
    'skip_gen_thres': 0.5, # Fraction of results to get back before moving on
    'skip_gen_timeout': 0.0 # Timeout when skip_gen_thres activates
}

class Optimizer(object):
    def __init__(self, hyperparameters):
        self.hyperparameters = hyperparameters

        self.opts = cma.CMAOptions()
        for param, value in OPTIMIZER_CONFIG.iteritems():
            if param in self.opts and value is not None:
                self.opts[param] = value
        self.dim = 0
        for h in self.hyperparameters:
            assert self.dim == h.index
            self.dim += h.array_length if h.array_length is not None else 1

        self.init = np.empty(self.dim)
        self.sigma = SIGMA0
        self.gen = 0; self.best_fitness = 0.0; self.mean_fitness = 0.0

        for h in self.hyperparameters:
            if h.array_length is None:
                if h.rand_init:
                    self.init[h.index] = random.random() * (h.max_range - \<commit_msg>fixed a bunch of bugs<commit_after>import copy
import numpy as np
import cma
import math
import random
import copy

SIGMA0 = 0.25
EPSILON = 1e-12

# Overwrite the parameters of CMAES
OPTIMIZER_CONFIG = {
    'popsize': 3,
}

# Termination criterion for stopping CMAES
TERM_CRITERION = {
    'generation': 20, # Number of generation to run to
    'fitness': 999, # Threshold fitness to reach
    'skip_gen_thres': 1.0, # Fraction of results to get back before moving on
    'skip_gen_timeout': 999 # Timeout when skip_gen_thres activates
}

class Optimizer(object):
    def __init__(self, hyperparameters):
        self.hyperparameters = hyperparameters

        self.opts = cma.CMAOptions()
        for param, value in OPTIMIZER_CONFIG.iteritems():
            if param in self.opts and value is not None:
                self.opts[param] = value
        self.dim = 0
        for h in self.hyperparameters:
            assert self.dim == h.index
            self.dim += h.array_length if h.array_length is not None else 1

        self.init = np.empty(self.dim)
        self.sigma = SIGMA0
        self.gen = 0; self.best_fitness = 0.0; self.mean_fitness = 0.0

        for h in self.hyperparameters:
            if h.array_length is None:
                if h.rand_init:
                    self.init[h.index] = random.random() * (h.max_range - \
{'fraction_non_alphanumeric': 0.08525688756515264, 'fraction_numerical': 0.0189873417721519, 'mean_word_length': 2.384130982367758, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '107258', 'n_tokens_mistral': 887, 'n_tokens_neox': 827, 'n_words': 262}