DEAP包用于Python中的遗传算法。

huangapple go评论59阅读模式
英文:

DEAP package for genetic algorithm in pyhton

问题

"toolbox.register('binary', bernoulli.rvs, 0.5)" 中的 "bernoulli" 是伯努利分布的意思。

英文:

The DEAP package which is used to execute GA has the below codes and can be found here 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)

Can anyone please let me know what is the meaning of bernoulli in the line "toolbox.register('binary', bernoulli.rvs, 0.5)" ?

答案1

得分: 0

Sure.
我们正在讨论伯努利分布,如此处所定义的。

英文:

> let me know what is the meaning of bernoulli ?

Sure.
We're talking about the
Bernoulli distribution,
as defined
here.

huangapple
  • 本文由 发表于 2023年1月9日 15:59:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/75054464.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定