TensorFlow (4-2) TensorFlow CNN Functions
1. Using TensorFlow to construct a CNN :
來介紹一些 CNN 會用到的 TensorFlow Functions 和一些有的沒的。
2. 輸入:
對一 CNN 的輸入要先定義輸入的下列參數:
- w: the width of the input.
- h: the height of the input.
- d: the depth of the input.
- p: the size of the padding of the input(zero padding).
3. Filter, Spatial Extent and Stride:
- Filter: 捲積的 mask。
- The spatial extent e, which is equal to the filter's height and width.
- The stride means the distance between consecutive applications of the filter on the input volume.
4. 舉個實際的例子
5. Convolution with Tensorflow Function:
tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding='SAME')
- x: a four-dimensional tensor of size N × h × w × d.
- W: a four-dimensional tensor of size e × e × d × k.
- strides: a list of ints. 1-D tensor of length 4. The stride of the sliding window for each dimension of input.
- padding: setting padding to 'SAME' means that the borders of x are padded such that the size of the result of the operation is the same as the size of x.
6. Pooling with Tensorflow Function:
tf.nn.max_pool(x, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME')
- x: a four-dimensional tensor of size N × h × w × d.
- ksize: a 1-D int Tensor of 4 elements. The size of the window for each dimension of the input tensor.
- strides: A 1-D int Tensor of 4 elements. The stride of the sliding window for each dimension of the input tensor.
- padding: A string, either 'VALID' or 'SAME'.
Reference
[1] Tom Hope, Yehezkel S. Resheff, and Itay Lieder, Learning TensorFlow A Guide to Building Deep Learning Systems , O'Reilly Media (2017)
[2] Nikhil Buduma, Fundamentals of Deep Learning Designing Next-Generation Machine Intelligence Algorithms, O'Reilly Media (2017)
[3] Aurélien Géron, Hands-On Machine Learning with Scikit-Learn and TensorFlow Concepts, Tools, and Techniques to Build Intelligent Systems , O'Reilly Media (2017)
留言
張貼留言