




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
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. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 市政工程24小時(shí)施工方案
- 2025【設(shè)備安裝工程施工合同補(bǔ)充協(xié)議】合同補(bǔ)充協(xié)議解析
- 一年級(jí)體育上冊(cè) 第三十四課跳短繩教學(xué)設(shè)計(jì)
- 線路電桿施工方案
- 2025丙方租房合同協(xié)議
- 旅游公司的全方位解析
- 湖北省襄陽(yáng)市第四十七中學(xué)八年級(jí)信息技術(shù)上冊(cè)《第二部分 Excel電子表格》教學(xué)設(shè)計(jì) 人教新課標(biāo)版
- 法醫(yī)學(xué)肺炎死因鑒定
- 根尖周病知識(shí)總結(jié)
- (2024年秋季版)七年級(jí)歷史上冊(cè) 第18課 東晉南朝時(shí)期江南地區(qū)的開發(fā)教學(xué)設(shè)計(jì) 新人教版
- 電線電纜安全生產(chǎn)培訓(xùn)
- 2025年北京科技職業(yè)學(xué)院高職單招職業(yè)技能測(cè)試近5年??及鎱⒖碱}庫(kù)含答案解析
- 汽車底盤構(gòu)造課件:離合器
- 2025年度貨車司機(jī)招聘廣告發(fā)布合同3篇
- 基于幾類機(jī)器學(xué)習(xí)模型預(yù)測(cè)肥胖成因的分析比較
- 2025年度科室質(zhì)控方案計(jì)劃
- 違規(guī)吊裝施工的報(bào)告范文
- 南京理工大學(xué)泰州科技學(xué)院《電路》2023-2024學(xué)年第一學(xué)期期末試卷
- 人教版九上《Unit 10 Youre supposed to shake hands》作業(yè)設(shè)計(jì)
- 《防范于心反詐于行》中小學(xué)防范電信網(wǎng)絡(luò)詐騙知識(shí)宣傳課件
- 大象版小學(xué)科學(xué)新版四年級(jí)上冊(cè)科學(xué)實(shí)驗(yàn)記錄單
評(píng)論
0/150
提交評(píng)論