娣卞害瀛︿範鎴樹簤锛欶acebook 鏀寔鐨?PyTorch 涓?Google 鐨?TensorFlow | Linux 涓浗
Posted Linux涓浗
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了娣卞害瀛︿範鎴樹簤锛欶acebook 鏀寔鐨?PyTorch 涓?Google 鐨?TensorFlow | Linux 涓浗相关的知识,希望对你有一定的参考价值。
銆€浣滆€呫€€|銆€Savia Lobo
銆€璇戣€呫€€|銆€Wuod3n 馃専 馃専 鍏辫缈昏瘧锛?span class="mq-16">2 绡?璐$尞鏃堕棿锛? 澶?/span>
鏈変竴涓护浜洪渿鎯婄殑浜嬪疄锛屽嵆浜哄伐鏅鸿兘鍜屾満鍣ㄥ涔犵殑宸ュ叿鍜屾妧鏈湪杩戞湡杩呴€熷叴璧枫€傛繁搴﹀涔狅紝鎴栬€呰鈥滄敞灏勪簡婵€绱犵殑鏈哄櫒瀛︿範鈥濓紝鏁版嵁绉戝瀹跺拰鏈哄櫒瀛︿範涓撳鍦ㄨ繖涓鍩熸湁鏁颁笉鑳滄暟绛夊彲鐢ㄧ殑搴撳拰妗嗘灦銆傚緢澶氳繖鏍风殑妗嗘灦閮芥槸鍩轰簬 Python 鐨勶紝鍥犱负 Python 鏄竴涓洿閫氱敤锛岀浉瀵圭畝鍗曠殑璇█銆?span class="mq-19">Theano[1]銆?span class="mq-21">Keras[2]銆?nbsp;TensorFlow[3] 鏄嚑涓熀浜?Python 鏋勫缓鐨勬祦琛岀殑娣卞害瀛︿範搴擄紝鐩殑鏄娇鏈哄櫒瀛︿範涓撳鏇磋交鏉俱€?/p>
Google 鐨?TensorFlow 鏄竴涓骞挎硾浣跨敤鐨勬満鍣ㄥ涔犲拰娣卞害瀛︿範妗嗘灦銆?TensorFlow 寮€婧愪簬 2015 骞达紝寰楀埌浜嗘満鍣ㄥ涔犱笓瀹剁ぞ鍖虹殑骞挎硾鏀寔锛孴ensorFlow 宸茬粡杩呴€熸垚闀夸负璁稿鏈烘瀯鏍规嵁鍏舵満鍣ㄥ涔犲拰娣卞害瀛︿範绛夐渶姹傝€岄€夋嫨鐨勬鏋躲€?鍙︿竴鏂归潰锛孭yTorch 鏄敱 Facebook 鏈€杩戝紑鍙戠殑鐢ㄤ簬璁粌绁炵粡缃戠粶鐨?Python 鍖咃紝鏀圭紪鑷熀浜?Lua 鐨勬繁搴﹀涔犲簱 Torch銆?PyTorch 鏄皯鏁板彲鐢ㄧ殑娣卞害瀛︿範妗嗘灦涔嬩竴锛屽畠浣跨敤鍩轰簬纾佸甫鐨勮嚜鍔ㄦ搴︾郴缁?rt class="mq-27">tape-based autograd system锛屼互蹇€熷拰鐏垫椿鐨勬柟寮忔瀯寤哄姩鎬佺缁忕綉缁溿€?/p>
鍦ㄨ繖绡囨枃绔犱腑锛屾垜浠皢 PyTorch 涓?TensorFlow 杩涜涓嶅悓鏂归潰鐨勬瘮杈冦€?/p>
璁╂垜浠紑濮嬪惂锛?/p>
浠€涔堢紪绋嬭瑷€鏀寔 PyTorch 鍜?TensorFlow锛?/p>
铏界劧涓昏鏄敤 C++ 鍜?CUDA 缂栧啓鐨勶紝浣?TensorFlow 鍖呭惈涓€涓綅浜庢牳蹇冨紩鎿庝笂鐨?Python API锛屼娇寰楁洿渚夸簬琚?ruby class="mq-32">Python 鏀寔鑰?rt class="mq-33">Pythonistas浣跨敤銆?闄や簡 Python锛屽畠杩樺寘鎷?C++銆丠askell銆丣ava銆丟o 鍜?Rust 绛夊叾浠?API锛岃繖鎰忓懗鐫€寮€鍙戜汉鍛樺彲浠ョ敤浠栦滑鐨勯閫夎瑷€杩涜缂栫爜銆?/p>
铏界劧 PyTorch 鏄竴涓?Python 杞欢鍖咃紝浣嗕綘涔熷彲浠ユ彁渚涗娇鐢ㄥ熀鏈殑 C/C++ 璇█鐨?API 杩涜缂栫爜銆?濡傛灉浣犱範鎯娇鐢?Lua 缂栫▼璇█锛屼綘涔熷彲浠ヤ娇鐢?Torch API 鍦?PyTorch 涓紪鍐欑缁忕綉缁滄ā鍨嬨€?/p>
PyTorch 鍜?TensorFlow 鏈夊涔堟槗浜庝娇鐢紵
濡傛灉灏?TensorFlow 浣滀负涓€涓嫭绔嬬殑妗嗘灦浣跨敤锛屽畠鍙兘浼氭湁鐐瑰鏉傦紝骞朵笖浼氱粰娣卞害瀛︿範妯″瀷鐨勮缁冨甫鏉ヤ竴浜涘洶闅俱€?涓轰簡鍑忓皯杩欑澶嶆潅鎬э紝鍙互浣跨敤浣嶄簬 TensorFlow 澶嶆潅寮曟搸涔嬩笂鐨?Keras 灏佽锛屼互绠€鍖栨繁搴﹀涔犳ā鍨嬬殑寮€鍙戝拰璁粌銆?TensorFlow 涔熸敮鎸?PyTorch 鐩墠娌℃湁鐨?span class="mq-37">鍒嗗竷寮忓煿璁?/span>[4]銆?鐢变簬鍖呭惈 Python API锛孴ensorFlow 涔熷彲浠ュ湪鐢熶骇鐜涓娇鐢紝鍗冲彲鐢ㄤ簬鍩硅缁冨拰閮ㄧ讲浼佷笟绾ф繁搴﹀涔犳ā鍨嬨€?/p>
PyTorch 鐢变簬 Torch 鐨勫鏉傜敤 Python 閲嶅啓銆?杩欎娇寰?PyTorch 瀵逛簬寮€鍙戜汉鍛樻洿涓哄師鐢熴€?瀹冩湁涓€涓槗浜庝娇鐢ㄧ殑妗嗘灦锛屾彁渚涙渶澶у寲鐨勭伒娲诲拰閫熷害銆?瀹冭繕鍏佽鍦ㄨ缁冭繃绋嬩腑蹇€熸洿鏀逛唬鐮佽€屼笉濡ㄧ鍏舵€ц兘銆?濡傛灉浣犲凡缁忔湁浜嗕竴浜涙繁搴﹀涔犵殑缁忛獙锛屽苟涓斾互鍓嶄娇鐢ㄨ繃 Torch锛岄偅涔堝熀浜庡畠鐨勯€熷害銆佹晥鐜囧拰鏄撶敤鎬э紝浣犱細鏇村枩娆?PyTorch銆?PyTorch 鍖呭惈瀹氬埗鐨?GPU 鍒嗛厤鍣紝杩欎娇寰楁繁搴﹀涔犳ā鍨嬪叿鏈夋洿楂樼殑鍐呭瓨鏁堢巼銆?鐢辨锛岃缁冨ぇ鍨嬫繁搴﹀涔犳ā鍨嬪彉寰楁洿瀹规槗銆?鍥犳锛孭ytorch 鍦?Facebook銆乀witter銆丼alesforce 绛夊ぇ鍨嬬粍缁囧箍鍙楁杩庛€?/p>
鐢?PyTorch 鍜?TensorFlow 璁粌娣卞害瀛︿範妯″瀷
PyTorch 鍜?TensorFlow 閮藉彲浠ョ敤鏉ュ缓绔嬪拰璁粌绁炵粡缃戠粶妯″瀷銆?/p>
TensorFlow 宸ヤ綔浜?SCG锛堥潤鎬佽绠楀浘锛変笂锛屽寘鎷湪妯″瀷寮€濮嬫墽琛屼箣鍓嶅畾涔夐潤鎬佸浘銆?浣嗘槸锛屼竴鏃﹀紑濮嬫墽琛岋紝鍦ㄦā鍨嬪唴鐨勮皟鏁存洿鏀圭殑鍞竴鏂规硶鏄娇鐢?nbsp;tf.session and tf.placeholder tensors[5]銆?/p>
PyTorch 闈炲父閫傚悎璁粌 RNN锛堥€掑綊绁炵粡缃戠粶锛夛紝鍥犱负瀹冧滑鍦?nbsp;PyTorch[6] 涓瘮鍦?TensorFlow 涓繍琛屽緱鏇村揩銆?瀹冮€傜敤浜?DCG锛堝姩鎬佽绠楀浘锛夛紝鍙互闅忔椂鍦ㄦā鍨嬩腑瀹氫箟鍜屾洿鏀广€?鍦?DCG 涓紝姣忎釜妯″潡鍙互鍗曠嫭璋冭瘯锛岃繖浣垮緱绁炵粡缃戠粶鐨勮缁冩洿绠€鍗曘€?/p>
TensorFlow 鏈€杩戞彁鍑轰簡 TensorFlow Fold锛岃繖鏄竴涓棬鍦ㄥ垱寤?TensorFlow 妯″瀷鐨勫簱锛岀敤浜庡鐞嗙粨鏋勫寲鏁版嵁銆?鍍?PyTorch 涓€鏍凤紝瀹冨疄鐜颁簡 DCG锛屽湪 CPU 涓婃彁渚涢珮杈?10 鍊嶇殑璁$畻閫熷害锛屽湪 GPU 涓婃彁渚涜秴杩?100 鍊嶇殑璁$畻閫熷害锛?鍦?nbsp;Dynamic Batching[7] 鐨勫府鍔╀笅锛屼綘鐜板湪鍙互鎵ц灏哄鍜岀粨鏋勯兘涓嶇浉鍚岀殑娣卞害瀛︿範妯″瀷銆?/p>
GPU 鍜?CPU 浼樺寲鐨勬瘮杈?/p>
TensorFlow 鐨勭紪璇戞椂闂存瘮 PyTorch 鐭紝涓烘瀯寤虹湡瀹炰笘鐣岀殑搴旂敤绋嬪簭鎻愪緵浜嗙伒娲绘€с€?瀹冨彲浠ヤ粠 CPU銆丟PU銆乀PU銆佺Щ鍔ㄨ澶囧埌 Raspberry Pi锛堢墿鑱旂綉璁惧锛夌瓑鍚勭澶勭悊鍣ㄤ笂杩愯銆?/p>
鍙︿竴鏂归潰锛孭yTorch 鍖呮嫭寮犻噺璁$畻锛屽彲浠ヤ娇鐢?GPU 灏嗘繁搴︾缁忕綉缁滄ā鍨嬪姞閫熷埌 50 鍊嶆垨鏇村[8]銆?杩欎簺寮犻噺鍙互鍋滅暀鍦?CPU 鎴?GPU 涓娿€?CPU 鍜?GPU 閮芥槸鐙珛鐨勫簱锛?鏃犺绁炵粡缃戠粶澶у皬濡備綍锛孭yTorch 閮藉彲浠ラ珮鏁堝湴鍒╃敤銆?/p>
绀惧尯鏀寔
TensorFlow 鏄綋浠婃渶娴佽鐨勬繁搴﹀涔犳鏋朵箣涓€锛岀敱姝や篃缁欏畠甯︽潵浜嗗簽澶х殑绀惧尯鏀寔銆?瀹冩湁寰堝ソ鐨勬枃妗e拰涓€濂楄缁嗙殑鍦ㄧ嚎鏁欑▼銆?TensorFlow 杩樺寘鎷澶氶鍏堣缁冭繃鐨勬ā鍨嬶紝杩欎簺妯″瀷鎵樼鍜屾彁渚涗簬 GitHub[9]銆?杩欎簺妯″瀷鎻愪緵缁欑儹琛蜂簬浣跨敤 TensorFlow 寮€鍙戣€呭拰鐮旂┒浜哄憳涓€浜涚幇鎴愮殑鏉愭枡鏉ヨ妭鐪佷粬浠殑鏃堕棿鍜岀簿鍔涖€?/p>
鍙︿竴鏂归潰锛孭yTorch 鐨勭ぞ鍖虹浉瀵硅緝灏忥紝鍥犱负瀹冩渶杩戞墠鍙戝睍璧锋潵銆?涓?TensorFlow 鐩告瘮锛屾枃妗e苟涓嶆槸寰堝ソ锛屼唬鐮佷篃涓嶆槸寰堝鏄撹幏寰椼€?鐒惰€岋紝PyTorch 纭疄鍏佽涓汉涓庝粬浜哄垎浜粬浠殑棰勮缁冩ā鍨嬨€?/p>
PyTorch 鍜?TensorFlow 鈥斺€?鍔涢噺鎮畩鐨勬晠浜?/p>
灏辩洰鍓嶈€岃█锛岀敱浜庡悇绉嶅師鍥狅紝TensorFlow 鏄剧劧姣?PyTorch 鏇村彈闈掔潗銆?/p>
TensorFlow 寰堝ぇ锛岀粡楠屼赴瀵岋紝鏈€閫傚悎瀹為檯搴旂敤銆?鏄ぇ澶氭暟鏈哄櫒瀛︿範鍜屾繁搴﹀涔犱笓瀹舵槑鏄剧殑閫夋嫨锛屽洜涓哄畠鎻愪緵浜嗗ぇ閲忕殑鍔熻兘锛屾渶閲嶈鐨勬槸瀹冨湪甯傚満涓婄殑鎴愮啛搴旂敤銆?瀹冨叿鏈夋洿濂界殑绀惧尯鏀寔浠ュ強澶氳瑷€ API 鍙敤銆?瀹冩湁涓€涓緢濂界殑鏂囨。搴擄紝鐢变簬浠庡噯澶囧埌浣跨敤鐨勪唬鐮佷娇涔嬫槗浜庣敓浜с€?鍥犳锛屽畠鏇撮€傚悎鎯宠寮€濮嬫繁搴﹀涔犵殑浜猴紝鎴栬€呭笇鏈涘紑鍙戞繁搴﹀涔犳ā鍨嬬殑缁勭粐銆?/p>
铏界劧 PyTorch 鐩稿杈冩柊锛岀ぞ鍖鸿緝灏忥紝浣嗗畠閫熷害蹇紝鏁堢巼楂樸€?鎬讳箣锛屽畠缁欎綘鎵€鏈夌殑浼樺娍鍦ㄤ簬 Python 鐨勬湁鐢ㄦ€у拰鏄撶敤鎬с€?鐢变簬鍏舵晥鐜囧拰閫熷害锛屽浜庡熀浜庣爺绌剁殑灏忓瀷椤圭洰鏉ヨ锛岃繖鏄竴涓緢濂界殑閫夋嫨銆?濡傚墠鎵€杩帮紝Facebook銆乀witter 绛夊叕鍙告鍦ㄤ娇鐢?PyTorch 鏉ヨ缁冩繁搴﹀涔犳ā鍨嬨€?浣嗘槸锛屼娇鐢ㄥ畠灏氭湭鎴愪负涓绘祦銆?PyTorch 鐨勬綔鍔涙槸鏄捐€屾槗瑙佺殑锛屼絾瀹冭繕娌℃湁鍑嗗濂藉幓鎸戞垬杩欎釜 TensorFlow 閲庡吔銆?鐒惰€岋紝鑰冭檻鍒板畠鐨勫闀匡紝PyTorch 杩涗竴姝ヤ紭鍖栧苟鎻愪緵鏇村鍔熻兘鐨勬棩瀛愬苟涓嶉仴杩滐紝鐩村埌涓?TensorFlow鍙互 姣旇緝銆?/p>
via: https://datahub.packtpub.com/deep-learning/dl-wars-pytorch-vs-tensorflow/
鏈枃鐢?nbsp;LCTT 鍘熷垱缂栬瘧锛?span class="mq-72">Linux涓浗 鑽h獕鎺ㄥ嚭
以上是关于娣卞害瀛︿範鎴樹簤锛欶acebook 鏀寔鐨?PyTorch 涓?Google 鐨?TensorFlow | Linux 涓浗的主要内容,如果未能解决你的问题,请参考以下文章