Understanding TensorFlow Parameters

tf.nn.conv2d(input, filter, strides, padding, use_cudnn_on_gpu=None, data_format=None, name=None)

Input :  [batch, input_height, input_width, input_channels]

  1. Filter / weight : [filter_height, filter_width, in_channels, out_channels]The second layer will have the depth = desired_output_channels
  2. Strides : [batch, height, width, channel].
    A stride of sliding windows for each dimension. With [1, 2 , 2 , 1] we are saying that we don’t want to slide across batch and channel and that we want to slide by 2 when it comes to height and width i.e
    [10 11 12 13 14 …
    20 21 22 23 24 …
    30 31 32 33 34 … ]
  3. Stride (patch-2 x2) [1, 1, 1, 1] [1, 2, 2, 1]
    Filter1 10 11 10 11
    20 21 20 21
    Filter2 11 12 12 13
    21 22 22 23

    3. Padding :  Padding algorithm to use. “SAME” or “VALID”

TensorFlow Max-Pooling:

tf.nn.max_pool(value, ksize, strides, padding, data_format='NHWC', name=None)

Each pooling uses a rectangular window of size ksize (Kernel Size) separated by offset strides i.e For a 28 x 28 image with ksize = [1,2,2,1] and stride = [1,2,2,1] reduces the input image to 14 x 14

  1. ksize : (Kernel Size) Rectangular window size over which the average is to be done.
  2. stride : How the rectangular window is to be slided across the whole image i.e Slide 1 px at a time or skip 1 px and take next px

 

Ref:

1 https://www.tensorflow.org/api_docs/python/nn/convolution

2.https://www.tensorflow.org/tutorials/mnist/pros/

 

Advertisements