morvanzhou / evolutionary-algorithm Goto Github PK
View Code? Open in Web Editor NEWEvolutionary Algorithm using Python, 莫烦Python 中文AI教学
Home Page: https://mofanpy.com/tutorials/machine-learning/evolutionary-algorithm/
License: MIT License
Evolutionary Algorithm using Python, 莫烦Python 中文AI教学
Home Page: https://mofanpy.com/tutorials/machine-learning/evolutionary-algorithm/
License: MIT License
Hi.
Gym is updated and now have warning:
WARN: gym.spaces.Box autodetected dtype as <class 'numpy.float32'>. Please provide explicit dtype.
使用 repeat 导致初始种群所有个体都有相同的 DNA; 正确做法是 pop = np.random.randint(2, size=(POP_SIZE, DNA_SIZE)) 使种群每个个体拥有随机的基因;
crossover 在求函数最大最小值一般采用单点交叉, 类似生物体染色体交叉, 而非对每一个基因座做交叉, 单点交叉示意如下
A: 10110111|00 crossover A': 10110111|11
B: 00011100|11 --------> B': 00011100|00
并且在做交叉时, 需要对个体进行两两配对, 而非从整体中随机选择, 这会导致群体内的部分已经过 select 个体繁殖几率不同. 从原理上来说, 经过 select 的个体必须拥有相同的繁殖几率.
Hey!
I am working on some code with open cv to track the percentage of frames in which my face is detected in terms of "attention span". I intend to optimize this attention span with an evolutionary solver that iterates a combination of diffused and direct light levels in my environment with an arduino board. Owing to the long range of time over which a generation of light levels need to be iterated I am unsure as to the best Evolutionary algorithm library or approach i can use to do this. I am currently not connected to an arduino and am just trying to do this with dummy numbers (1-4,1-4) for diffused and direct respectively. The idea is that every 15 mins or so ( lets say 50,000 frames) the light levels assume a new and improved combination and wait for another 15.
I am new to python and coding in general so I am finding it harder to figure out which library and it's ideal implementation for this purpose I'd be grateful if you have any advice.
when DNA_SIZE > 1, index out of boundary at
good_idx = idx[fitness.argsort()][-POP_SIZE:]
so, suggestion is :
def kill_bad(pop, kids):
# put pop and kids together
for key in ['DNA', 'mut_strength']:
pop[key] = np.vstack((pop[key], kids[key]))
fitness = get_fitness(F(pop['DNA'])) # calculate global fitness
w,h = pop['DNA'].shape
idx = np.arange(w*h)
good_idx = idx[fitness.argsort()][-POP_SIZE*DNA_SIZE:] # selected by fitness ranking (not value)
for key in ['DNA', 'mut_strength']:
pop[key] = pop[key].flatten()
pop[key] = pop[key][good_idx]
pop[key] = pop[key].reshape((POP_SIZE,DNA_SIZE))
return pop
Hi Morvan, amazing work!
It is really helping me understand GAs. I am curious how could I add the constraint of having to come back to the original position, so the travel is a round trip.
In which part should the constraint be added?
Thanks in advance!
Regards,
Pablo
莫烦哥你好,我想问一下这个地方为什么又执行 p.run(eval_genomes, 10) 这个函数,前面不都是已经训练好了吗,最后为什么又训练了10次
p = neat.Checkpointer.restore_checkpoint('neat-checkpoint-49')
p.run(eval_genomes, 10)
在代码的进化中,我认为变异强度并不是自适应地往低值走,它主要还是决定于最初达到峰值的学习点对应的'mut_strength‘,在basic和(1+1)中都可以体现(我是进行了输出。结果只是趋向于某一个值而已),我的想法是DNA与函数峰值的差去决定变异强度(当然这只能用于这两个代码)。如果我的想法有错误,也请你告诉我,谢谢!
Hi, your tutorials are awesome! I just start learning python & machine learning and not without your help.
Regarding "Evolutionary-Algorithm / tutorial-contents / Using Neural Nets / Evolution Strategy with Neural Nets.py":
Thanks a lots.
为什么要用正态分布去改变DNA
如何保证在DNA逐渐优化的过程中,变异强度会逐渐减弱。也是依靠计算机随机的选择么?
你好!感谢你的视频分享,很通俗易懂!但是我有一点小疑问,如下:
for parent in pop:
child = crossover(parent, pop_copy)
child = mutate(child)
parent[:] = child # parent is replaced its child
我对这一段代码的最后一句有一点疑惑,就是为什么要重新更改parent的值呢?它在for循环里作为迭代变量,更改它的值是不是没有意义啊?为什么不是把child的值更新到pop里面?
谢谢你!
您好,莫烦老师,非常感谢你的视频分享。
我对ES neuroevolution的算法有个疑问想请教下,你的算法中只用了20个individuals就可以起到比较好的效果了,我看openai的算法,为什么他们需要1000个才行?而且我将openai算法中的individuals的数量减少了,似乎他们的算法就无法收敛了。
After long using of Evolution Strategy with Neural Nets.py have MemoryError in Multiprocessing.
Memory filled up each step, posible to clean up it?
Hello,
how does one save an evolved model and then load one for later use?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.