版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
HowtoEvolveLifeinaComputerusingPython
BertChan
BigDataConsultant@ASL
PyConHK/CodeConf2018
Programminginthe1990’s
PC:80286(8MHz,8MBRAM)
OS:MS-DOS(Win3.1tooslow!)
Pascal
Simulatelife
Simulategravity,fractals
Hack&decodegames
Assembly
Mainloop–veryfast!
Directwritetovideocache
Ifyoudidcodingandhackedstuffsinthe90’s,you’rea…
SimulateLife
Conway’sGameofLife
JohnConway1970
CellularAutomata–arrayofcells(0or1)
Neighborhood(8cells,sum)
Simpleif-then-elserule
forcellincells:
ifcell==1andsumin[2,3]:cell=1 #surviveelifcell==0andsumin[3]:cell=1 #bornelse:cell=0 #die
cell:0or1
1
0 0
0
1
1
0
0
0
neighborhood
Conway’sGameofLife
Themovingglider
Greencellssurvive,bluecellsareborn,redcellsdie
Spaceships,glidergun…
Logicgate,clock,computer…
Hackersloveit!
Goodwaytolearnprogramming!
Playwiththerules
Whatifwe…
cell:0or1
0
0 0
0
1
0
0
0
0
neighborhood(n)
sum=σ𝑛
cell=(ifsum…then…else…)
Playwiththerules
Whatifwe…
Usefloatingpoint?
realnumber
0.12
0.02 0.00
0.95
0.36
0.17
0.46
0.53
0.22
neighborhood(n)
sum=σ𝑛
cell=(ifsum…then…else…)
Playwiththerules
Whatifwe…
Usefloatingpoint?
Biggerneighborhood?Circular?
realnumber
0.36
neighborhood(n)
sum=σ𝑛
cell=(ifsum…then…else…)
Playwiththerules
Whatifwe…
Usefloatingpoint?
Biggerneighborhood?Circular?
Weightedsum?
realnumber
*
neighborhood(n) weights(k)
sum=σ𝑛𝑘
cell=(ifsum…then…else…)
Playwiththerules
realnumber
Whatifwe…
Usefloatingpoint?
Biggerneighborhood?Circular?
Weightedsum?
Smoothupdate?
*
neighborhood(n)
weights(k)
sum=σ𝑛𝑘
cell=cell+0.1*f(sum)
Playwiththerules
Whatifwe…
Usefloatingpoint?
Biggerneighborhood?Circular?
Weightedsum?
Smoothupdate?
Spookythingshappened…
OMGWHATISTHIS??
Lenia
NewkindofArtificialLife
Microorganism-likecreatures
Discovered400+species
Studytheiranatomy,behavior,physiology…
Goodprogrammingexercise
JavaScript,C#,MATLAB,Python
Video
Pythonshowcasevideo
/277328815
Kyoto
WonGECCOVirtualCreaturesContest,Kyoto
HonorableMentioninALIFEArtAward,Tokyo
MeetmyAIhero–@hardmaru
DavidHa(GoogleBrainTokyo)
UsingPython
forPyConHK
WhyPython?
Goodperformance
Fastcoding
Nicesyntax(indent,listcomprehension,etc)
Lotsofusefullibraries
Vibrantcommunity(PyCon,GitHub…)
Matplotlib
PythonLibraries
“Rule34”ofPython
NumPy
Arraycalculations
Reikna
PyOpenCL/
PyCUDA
GPU
acceleration
SciPy/
OpenCV
PIL/Pillow
Imageprocessing
Tkinter
InteractiveUI
ffmpeg-python
subprocess+
ffmpeg
Recordvideo
“Ifthereisaneed,thereisaPythonlibraryforit.”
NumPy
Fastarraycalculations
Machinelearning,deeplearning
Basisofimageprocessing,time-series
Cellularautomata(weightedsumusingFFT)
MainloopofLeniain3lines
potential_fft=np.fft.fft2(cells)*kernel_fft
potential=np.fft.fftshift(np.real(np.fft.ifft2(potential_fft))
cells_new=np.clip(cells+dt*g(potential,m,s),0,1)
PyOpenCL/PyCUDA+Reikna
GPUacceleration
(NVIDIA)CUDAPyCUDA
(Apple)OpenCLPyOpenCL
Reikna
PyOpenCL/PyCUDAwrapper
CompilestheGPUcodeforyou
GPUacceleratedFFTinafewlines
gpu_thr=reikna.cluda.any_api().Thread.create()
gpu_fft=reikna.fft.FFT(cells.astype(plex64)).compile(gpu_thr)op_dev=gpu_thr.to_device(cells.astype(plex64))gpu_fft(op_dev,op_dev,**kwargs)
cells=op_dev.get()
PIL/Pillow,SciPy,OpenCV
Imagehandling
PIL(PythonImageLib)pillow
Createimage,drawlines/texts,saveGIF…
img=PIL.Image.frombuffer('P',buffer.shape,buffer,…)
draw=PIL.ImageDraw.Draw(img)
img[0].save(path,format='GIF',append_images=self.gif[1:],loop=0…)
Imageprocessing
SciPy
scipy.ndimage.rotate(A,reshape=False,order=0,mode='wrap’)
OpenCV-Python
TkintervsMatplotlib
InteractiveUI
Real-time2Dimagedisplay
Menu,keyboardbinding,clipboard
Matplotlib
Fordatavisualization
Powerfulbutslow…
Tkinter(Toolkitinterface)
Basicandfast
Others:wxPython,PyQt,PyGTK…
InteractiveUI
win=tk.Tk()tk.Canvas()tk.Menu()
win.bind('<Key>',key_press_event)
win.clipboard_get()
Python3
importtkinterastk
subprocess+ffmpeg
PythonicFFmpegwrappers
ffmpeg-python,ffmpy,etc.
Pipevideotoffmpeg
cmd=['/usr/local/bin/ffmpeg’,'-f','rawvideo',…]
video=subprocess.Popen(cmd,stdin=subprocess.PIPE)forimginimgs:
video.stdin.write(img.convert('RGB').tobytes())video.stdin.close()
AboutALifeandAI
forHKCodeConf
Lenia
Notjustfunnycreatures
UsingAItocreateALife
AboutALife
ArtificialLife
Simulatebiologicallifeorcreatenewlifeforms
Createabody
WetALife=biochemistry,syntheticlife
Artificialcell,expandedgeneticcode…
HardALife=hardware,robots&machines
Humanoids,Strandbeest…
SoftALife=software,simulations
Cellularautomata,virtualcreatures…
WetALife=biochemistry,syntheticlife
Artificialcell,expandedgeneticcode…
HardALife=hardware,robots&machines
Humanoids,Strandbeest…
Syntheticcell(JCVI,2010)
SoftALife=software,simulations
Cellularautomata,virtualcreatures…
ExpandedDNA(TSRI,2014)
WetALife=biochemistry,syntheticlife
Artificialcell,expandedgeneticcode…
HardALife=hardware,robots&machines
Humanoids,Strandbeest…
SoftALife=software,simulations
Cellularautomata,virtualcreatures…
Strandbeest(TheoJansen,1990)
Atlas(BostonDynamics,2017)
SoftALife=software,simulations
Cellularautomata,virtualcreatures…
HardALife=hardware,robots&machines
Humanoids,Strandbeest…
WetALife=biochemistry,syntheticlife
Artificialcell,expandedgeneticcode…
Virtualcreatures(KarlSims,1994)
Softrobots(NickCheney,2014)
AboutAI
EA=EvolutionaryAlgorithms
Neuro-evolution,novelty,etc
ArtificialIntelligence
Machinesdo:learning,planning,vision,language,emotion,art
ML=MachineLearning
Supervised,unsupervised,reinforced
DL=DeepLearning
Deepneuralnets+bigdata+manyGPU
GOFAI=Goodold-fashionedAI
Symbolic,expertsystems
Createamind
GOFAI=Goodold-fashionedAI
Symbolic,expertsystems
ML=MachineLearning
Supervised,unsupervised,reinforced
DL=DeepLearning
Deepneuralnets+bigdata+manyGPU
DeepBluevs.Kasparov(IBM,1997)
EA=EvolutionaryAlgorithms
Neuro-evolution,novelty,etc
WatsoninJeopardy!(IBM,2011)
GOFAI=Goodold-fashionedAI
Symbolic,expertsystems
AlphaGovs.LeeSedol(DeepMind,2016)
ML=MachineLearning
Supervised,unsupervised,reinforced
DL=DeepLearning
Deepneuralnets+bigdata+manyGPU
EA=EvolutionaryAlgorithms
Neuro-evolution,novelty,etc
Autopilot(Tesla,2014)
BigGAN(AndrewBrock,2018)
GOFAI=Goodold-fashionedAI
Symbolic,expertsystems
ML=MachineLearning
Supervised,unsupervised,reinforced
DL=DeepLearning
Deepneuralnets+bigdata+manyGPU
PicBreeder(EPlex,2007)
EA=EvolutionaryAlgorithms
Neuro-evolution,novelty,etc
Evolut
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 现在进行时练习题及答案
- 服务质量评价表
- 2024年液体气体过滤、净化机械项目投资申请报告代可行性研究报告
- 市场营销业绩协议
- 产业用房购买合同样本
- 广东省梅州市坭陂中学高一数学文测试题含解析
- 江苏省徐州市第三十七中学2022年高一数学文模拟试题含解析
- 重庆渝北区实验中学高一英语上学期摸底试题含解析
- 江苏省南京市五塘中学高一数学文下学期摸底试题含解析
- 2024年生化分析仪器项目资金需求报告
- 中等职业教育课程改革国家规划新教材计算机应用基础教案
- 中药化学知到章节答案智慧树2023年天津中医药大学
- 儿科十四五规划
- DISC职业性格测试(40题,附完整分析)
- 安徽省合肥市庐阳区第四十五中学2022-2023学年中考一模物理试卷(含答案)
- 2023年浙江杭州城市建设投资发展集团有限公司招聘笔试题库含答案解析
- 繁昌县繁星针织漂染有限责任公司纺织面料印染及功能整理智能化绿色产业链建设项目环境影响报告书
- 成语故事 百鸟朝凤 PPT
- 湖北十堰613爆炸事故反思 湖北十堰事故经验总结
- 高中英语 Module 2 Unit 6 The Admirable Lesson 1 A Medical Pioneer(Period1) 教学设计
- 安全生产费用记录台账
评论
0/150
提交评论