【问题标题】:DEAP package for genetic algorithm in pyhtonpython中遗传算法的DEAP包
【发布时间】:2023-01-09 16:05:35
【问题描述】:

用于执行 GA 的 DEAP 包具有以下代码,可以在这里找到 http://aqibsaeed.github.io/2017-08-11-genetic-algorithm-for-optimizing-rnn/

population_size = 4
num_generations = 4
gene_length = 10

# As we are trying to minimize the RMSE score, that's why using -1.0.
# In case, when you want to maximize accuracy for instance, use 1.0
creator.create('FitnessMax', base.Fitness, weights = (-1.0,))
creator.create('Individual', list , fitness = creator.FitnessMax)

toolbox = base.Toolbox()
toolbox.register('binary', bernoulli.rvs, 0.5)
toolbox.register('individual', tools.initRepeat, creator.Individual, toolbox.binary,
n = gene_length)
toolbox.register('population', tools.initRepeat, list , toolbox.individual)

toolbox.register('mate', tools.cxOrdered)
toolbox.register('mutate', tools.mutShuffleIndexes, indpb = 0.6)
toolbox.register('select', tools.selRoulette)
toolbox.register('evaluate', train_evaluate)

population = toolbox.population(n = population_size)
r = algorithms.eaSimple(population, toolbox, cxpb = 0.4, mutpb = 0.1,
ngen = num_generations, verbose = False)

谁能告诉我“toolbox.register('binary', bernoulli.rvs, 0.5)”这一行中 bernoulli 的含义是什么?

【问题讨论】:

    标签: python-3.x genetic-algorithm deap


    【解决方案1】:

    让我知道伯努利是什么意思?

    当然。 我们正在谈论 Bernoulli distribution, 定义 here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-12-26
      • 2018-01-18
      • 1970-01-01
      • 2017-05-30
      • 2018-06-25
      • 2016-10-18
      • 2023-04-01
      相关资源
      最近更新 更多