版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 購買土地抵押貸款合同范例
- 江西企業(yè)勞動合同范例
- 貨物定做合同范例
- 春節(jié)期間旅游服務合同范例
- 委托禮品購置合同范例
- 燒烤聚餐采購合同范例
- 工程清拆合同范例
- 主奴協(xié)議合同范例
- 退休教師勞務合同范例
- 外墻改造設計合同范例
- 高素質(zhì)農(nóng)民培育培訓
- 抖音團播行業(yè)報告
- 樂高-人形機器人搭建(圖1)
- 專題8-5條件概率與全概率公式貝葉斯公式8類題型
- 過程控制系統(tǒng)及儀表 王再英等 課后答案(全)
- 基于ABB工業(yè)機器人自動化搬運工作站的設計
- 電子競技2024年電子競技產(chǎn)業(yè)的新崛起
- 《綠色化學化工技術》課件
- 民法典中的勞動法與勞動糾紛解決的法律適用
- 廣東省廣州市黃埔區(qū)2023-2024學年八年級上學期期末生物試卷+
- 四川省達州市2023-2024學年八年級上學期期末歷史試題(含答案)
評論
0/150
提交評論