




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
2017-07-為什么選
為什么選高移植性在一個/CPUs或GPUs的筆記本電腦,服靈活性適用AndroidWindowsiOSLinux20,000commits6000TF-reposin1 七
為什么選使用Tensorflow的公●七
importtensorflowas
如果有同學(xué)想要更簡單的用TFLearn(tf.contrib.learn):習(xí)慣scikit-learnfit函數(shù) TFSlimtf.contrib.slim這是TensorFlow里的七
概念Graph和DataFlowGraphby七
概念Graph和Graphby七
Tensor+Graphby
Tensor是什在tensorflow里,大家可以理解成一個n0-dtensor標(biāo)量/數(shù)scalarnumber)1-dtensor:向量vector2-dtensor…
Numpyvs
在Tensorflow的計算圖里importtensorflowasx,y是什么Tensorflow在你沒有指定名稱的時候會自動命3a5x=3a5y=在“這幅圖”節(jié)點(diǎn):operators,variables,and邊
3a5在Tensorflow的計算圖3a5importtensorflowasa=tf.add(3,print>>Tensor("Add:0",shape=(),結(jié)果不是如何取到結(jié)果
初始化session,完成操importtensorflowasa=tf.add(3,5)sess=tf.Session()printsess.run(a)Session會在計算圖里找到a的依賴,把依賴的節(jié)點(diǎn)都進(jìn)行計
建議的session寫法如importtensorflowasa=tf.add(3,sess=withtf.Session()asprintSession會在計算圖里找到a的依賴,把依賴的節(jié)點(diǎn)都進(jìn)行計
我們來看一個復(fù)雜一點(diǎn)點(diǎn)的例x2y3=tf.add(x,=tf.mul(x,=tf.pow(op2,withtf.Session()asop3=
我們不需要的依賴,其實(shí)不會進(jìn)行計算,比如下面的例x=y=add_op=tf.add(x,y)mul_op=tf.mul(x,y)useless=tf.mul(x,add_op)pow_op=tf.pow(add_op,withtf.Session()asz=
如果我需要運(yùn)行幾個運(yùn)算節(jié)點(diǎn),比如上例中的x=y=add_op=tf.add(x,y)mul_op=tf.mul(x,y)useless=tf.mul(x,add_op)pow_op=tf.pow(add_op,withtf.Session()asz,not_useless=sess.run([pow_op,
更全的格式是下面這樣,我們把所有需要的變量編成list放到fetchesx=y=…tf.Session.run(fetches,options=None,
指定CPUorGPU去完成session里的運(yùn)算構(gòu)建witha=tf.constant([1.0,2.0,3.0,4.0,5.0,6.0],b=tf.constant([1.0,2.0,3.0,4.0,5.0,6.0],name='b')=tf.matmul(a,#構(gòu)建session,設(shè)置log_device_placement為sess=運(yùn)行op定義的運(yùn)print
回想useless例
了解圖結(jié)構(gòu)/可視化的利importtensorflowasa=b=x=tf.add(a,withtf.Session()aswriter=tf.summary.FileWriter('./graphs,printsess.run(x)writer.close(關(guān)閉writer
了解圖結(jié)構(gòu)/$python 瀏覽 七
看這24了解圖結(jié)構(gòu)/可視化的利importtensorflowasa=b=x=tf.add(a,withtf.Session()aswriter=tf.summary.FileWriter('./graphs,printsess.run(x)writer.close(關(guān)閉writer
自定義常量名稱可以自己指importtensorflowasa=tf.constant(2,b=tf.constant(3,name=“b")x=tf.add(a,b,name=“add”)withtf.Session()assess:writer=tf.summary.FileWriter('./graphs,sess.graph)printsess.run(x)writer.close(關(guān)閉
和numpy其實(shí)tf.constant(value,dtype=None,name='Const',importtensorflowasa=tf.constant([2,2],b=tf.constant([[0,1],[2,3]],x=tf.add(a,b,name="add")y=tf.mul(a,b,name="mul")withtf.Session()assess:x,y=sess.run([x,printx,#>>[58][6
七
tf.random_normal(shape,mean=0.0,dtype=tf.float32,seed=None,tf.truncated_normal(shape,mean=0.0,dtype=tf.float32,seed=None,tf.random_uniform(shape,minval=0,dtype=tf.float32,seed=None,name=None)tf.random_shuffle(value,seed=None,name=None)tf.random_crop(value,size,seed=None,name=None)tf.multinomial(logits,num_samples,seed=None,name=None)tf.random_gamma(shape,alpha,beta=None,dtype=tf.float32,seed=None,七
a=tf.constant([3,b=tf.constant([2,tf.add(a,b)#>>[5tf.add_n([a,b,b])#>>[7tf.mul(a,b)#>>[6tf.matmul(a,b)#>>tf.matmul(tf.reshape(a,[1,2]),tf.reshape(b,[2,1]))#>>tf.div(a,b)#>>[1tf.mod(a,b)#>>[1七
七
tf.constant是op,而tf.Variable是一個類,初始化的對象有多個#createvariableawithscalarvaluea=tf.Variable(2,name="scalar")#createvariablebasab=#createvariable
3],asa2x2c=tf.Variable([[0,1],[2,3]],#createvariableWas784x10tensor,filledwithW=七
tf.constant是op,而tf.Variable是一個類,初始化的對象有多個x=tf.Variable(...)x.initializer初始化x.value 的x.assign(..寫入的x.assign_add(...)七
init=withtf.Session()asinit_ab=tf.variables_initializer([a,b],withtf.Session()aswithtf.Session()assess:
W是一個700x100隨W=tf.Variable(tf.truncated_normal([700,withtf.Session()assess:printWprint>>Tensor("Variable/read:0",shape=(700, 七
Tensorflowtf.placeholder(dtype,shape=None,#createaplaceholderoftypefloat32-‐bit,shapeisavectorof3a=tf.placeholder(tf.float32,#createaconstantoftypefloat32-‐bit,shapeisavectorof3b=tf.constant([5,5,5],#usetheplaceholderasyouwouldaconstantorac=a+b#Shortfortf.add(a,withtf.Session()assess:printsess.run(c)#Errorbecauseadoesn’thaveany
Tensorflowtf.placeholder(dtype,shape=None,#createaplaceholderoftypefloat32-‐bit,shapeisavectorof3a=tf.placeholder(tf.float32,#createaconstantoftypefloat32-‐bit,shapeisavectorof3b=tf.constant([5,5,5],#usetheplaceholderasyouwouldaconstantorac=a+b#Shortfortf.add(a,withtf.Session()as#feed[1,2,3]toplaceholderaviathedict{a:[1,2,printsess.run(c,{a:[1,2,#thetensoraisthekey,notthestring#>>[6,7,
Tensorflowtf.placeholder(dtype,shape=None,#createoperations,tensors,etc(usingthed
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- xx工程項(xiàng)目旬報(項(xiàng)目進(jìn)展情況報告)
- 1 學(xué)會尊重 第一課時 教學(xué)設(shè)計-2023-2024學(xué)年道德與法治六年級下冊統(tǒng)編版
- 智慧排水管理系統(tǒng)方案可行性研究報告
- 曲靖市花椒加工項(xiàng)目可行性研究報告
- 【可行性報告】2025年彩妝化妝品項(xiàng)目可行性研究分析報告
- 2025年度個人租賃合同范本:租賃合同中的租金支付方式
- 2024-2030年中國導(dǎo)熱硅脂行業(yè)市場發(fā)展趨勢與前景展望戰(zhàn)略分析報告
- 三維固土網(wǎng)墊項(xiàng)目投資可行性研究分析報告(2024-2030版)
- 設(shè)備轉(zhuǎn)售合同范本
- 2025年度高端醫(yī)療器械銷售代理合同范本-@-1
- 《房地產(chǎn)開發(fā)與經(jīng)營》全套教學(xué)課件
- DL∕T 838-2017 燃煤火力發(fā)電企業(yè)設(shè)備檢修導(dǎo)則
- 銀行外拓營銷方法
- 湖北省武漢市江漢區(qū)2023-2024學(xué)年七年級下學(xué)期期末數(shù)學(xué)試題
- 四肢創(chuàng)傷影像(X線)診斷
- 2023年湖北省襄陽市中考地理真題(含解析)
- 2023-2024學(xué)年統(tǒng)編版高中語文選擇性必修下冊古詩詞誦讀《客至》課件
- 城市道路施工作業(yè)區(qū)規(guī)范資料匯編
- DL-T5153-2014火力發(fā)電廠廠用電設(shè)計技術(shù)規(guī)程
- 冀人版科學(xué)六年級下冊全冊同步練習(xí)
- (高清版)JTGT 3365-02-2020 公路涵洞設(shè)計規(guī)范
評論
0/150
提交評論