技术博客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

提交评论