技術博客tensorflow與教程covnets in_第1頁
技術博客tensorflow與教程covnets in_第2頁
技術博客tensorflow與教程covnets in_第3頁
技術博客tensorflow與教程covnets in_第4頁
技術博客tensorflow與教程covnets in_第5頁
已閱讀5頁,還剩38頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、Convnets in TensorFlowCS 20: TensorFlow for Deep Learning ResearchLecture 72/7/201712AgendaConvolutions without trainingConvnet with MNIST!tf.layers3Understanding convolutions4Convolutions in math and physics5a function derived from two given functions by integration that expresses how the shape of

2、one is modified by the otherConvolutions in math and physics6Brian Amberg derivative work (Wikipedia)Convolutions in math and physics7How an input is transformed by a kernel* *also called filter/feature mapConvolutions in machine learning8We can use one single convolutional layer to modify a certain

3、 imageConvolutions in machine learning9 Kernel for blurring100.06250.1250.06250.1250.250.1250.06250.1250.0625Matrix multiplication of this kernel with a 3 x 3 patch of an image is a weighted sum of neighboring pixels= blurring effectConvolution without training110.06250.1250.06250.1250.250.1250.0625

4、0.1250.0625tf.nn.conv2dinputKernel for blurringoutputConvolutions in TensorFlow12We can use one single convolutional layer to modify a certain imagetf.nn.conv2d( input, filter, strides, padding, use_cudnn_on_gpu=True, data_format=NHWC, dilations=1, 1, 1, 1, name=None)Convolutions in TensorFlow13We c

5、an use one single convolutional layer to modify a certain imagetf.nn.conv2d( input,Batch size (N) x Height (H) x Width (W) x Channels (C) filter,Height x Width x Input Channels x Output Channels strides,4 element 1-D tensor, strides in each direction padding,SAME or VALID use_cudnn_on_gpu=True, data

6、_format=NHWC, dilations=1, 1, 1, 1, name=None)Convolutions in TensorFlow14We can use one single convolutional layer to modify a certain imagetf.nn.conv2d( image, kernel, strides=1, 3, 3, 1, padding=SAME,)Some basic kernels15inputsharpenedgetop sobelembossSee kernels.py and 07_run_kernels.pySome basi

7、c kernels16inputsharpenedgetop sobelembossConvolutions in machine learning17Dont hard-code the values of your kernels.Learn the optimal kernels through training!ConvNet with MNIST18Model1928x28x15x5x1x32Conv + relu28x28x32Maxpool (2x2x1)Conv + reluMaxpool (2x2x1)Fully + reluFully + softmaxWeight5x5x

8、32x647*7*64 x 10241024 x 1014x14x3214x14x647 x 7 x 641 x 10241 x 10Strides for all convolutional layers: 1, 1, 1, 1Convolutional layer2028x28x15x5x1x32Conv + relu28x28x32Maxpool (2x2x1)Conv + reluMaxpool (2x2x1)Fully + reluFully + softmaxWeight5x5x32x647*7*64 x 10241024 x 1014x14x3214x14x647 x 7 x 6

9、41 x 10241 x 10conv = tf.nn.conv2d(images,kernel,strides=1, 1, 1, 1,padding=SAME)Convolutional layer: padding21Input width = 13Filter width = 6Stride = 5Convolutional layer: Dimension2228x28x15x5x1x32Conv + relu28x28x32Maxpool (2x2x1)Conv + reluMaxpool (2x2x1)Fully + reluFully + softmaxWeight5x5x32x

10、647*7*64 x 10241024 x 1014x14x3214x14x647 x 7 x 641 x 10241 x 10(WF+2P)/S+ 1W: input width/depthF: filter width/depthP: paddingS: strideConvolutional layer: Dimension23(WF+2P)/S+ 1W: input width/depthF: filter width/depthP: paddingS: strideImage credit: CS231n Lecture 7Convolutional layer: Dimension

11、2428x28x15x5x1x32Conv + relu28x28x32Maxpool (2x2x1)Conv + reluMaxpool (2x2x1)Fully + reluFully + softmaxWeight5x5x32x647*7*64 x 10241024 x 1014x14x3214x14x647 x 7 x 641 x 10241 x 10(WF+2P)/S+ 1(28 - 5 + 2*2)/1 + 1 = 28W: input width/depthF: filter width/depthP: paddingS: strideConvolutional layer: D

12、imension2528x28x15x5x1x32Conv + relu28x28x32Maxpool (2x2x1)Conv + reluMaxpool (2x2x1)Fully + reluFully + softmaxWeight5x5x32x647*7*64 x 10241024 x 1014x14x3214x14x647 x 7 x 641 x 10241 x 10(WF+2P)/S+ 1(28 - 5 + 2*2)/1 + 1 = 28W: input width/depthF: filter width/depthP: paddingS: strideTF computes pa

13、dding for us!Maxpooling2628x28x15x5x1x32Conv + relu28x28x32Maxpool (2x2x1)Conv + reluMaxpool (2x2x1)Fully + reluFully + softmaxWeight5x5x32x647*7*64 x 10241024 x 1014x14x3214x14x647 x 7 x 641 x 10241 x 10pool1 = tf.nn.max_pool(conv1,ksize=1, 2, 2, 1,strides=1, 2, 2, 1,padding=SAME)Maxpooling27Slide

14、credit: CS231n Lecture 71124567832101234Single depth slicexymax pool with 2x2 filters and stride 26834Maxpooling: Dimension2828x28x15x5x1x32Conv + relu28x28x32Maxpool (2x2x1)Conv + reluMaxpool (2x2x1)Fully + reluFully + softmaxWeight5x5x32x647*7*64 x 10241024 x 1014x14x3214x14x647 x 7 x 641 x 10241

15、x 10(WK+2P)/S+ 1W: input width/depthK: window width/depthP: paddingS: strideMaxpooling: Dimension2928x28x15x5x1x32Conv + relu28x28x32Maxpool (2x2x1)Conv + reluMaxpool (2x2x1)Fully + reluFully + softmaxWeight5x5x32x647*7*64 x 10241024 x 1014x14x3214x14x647 x 7 x 641 x 10241 x 10(WK+2P)/S+ 1(28 - 2 +

16、2*0) / 2 + 1 = 14W: input width/depthK: window width/depthP: paddingS: strideFully connected3028x28x15x5x1x32Conv + relu28x28x32Maxpool (2x2x1)Conv + reluMaxpool (2x2x1)Fully + reluFully + softmaxWeight5x5x32x647*7*64 x 10241024 x 1014x14x3214x14x647 x 7 x 641 x 10241 x 10fc = tf.matmul(pool2, w) +

17、bSoftmax3128x28x15x5x1x32Conv + relu28x28x32Maxpool (2x2x1)Conv + reluMaxpool (2x2x1)Fully + reluFully + softmaxWeight5x5x32x647*7*64 x 10241024 x 1014x14x3214x14x647 x 7 x 641 x 10241 x 10Loss functiontf.nn.softmax_cross_entropy_with_logits(labels=Y, logits=logits)Predicttf.nn.softmax(logits_batch)

18、Interactive coding3207_convnet_mnist_starter.py from GitHub!Update utils.py33Training progress34Test accuracy increases while training loss decreases!Accuracy35EpochsAccuracy10.913120.936330.947850.9573100.971250.9818tf.layers36tf.layers37Weve been learning it the hard waytf.layers.conv2d38conv1 = tf.layers.conv2d(inputs=self.img, filters=32, kernel_size=5, 5, padding=SAME, activation=tf.nn.relu, name=con

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論