Convolution and pooling operations in TensorFlow
Now that we have seen how convolutional and pooling operations are performed theoretically, let's see how we can perform these operation hands-on using TensorFlow. So let's get started.
Applying pooling operations in TensorFlow
Using TensorFlow, asubsampling layer can normally be represented by a max_pool
operation by maintaining the initial parameters of the layer. For max_pool
, it has the following signature in TensorFlow:
tf.nn.max_pool(value, ksize, strides, padding, data_format, name)
Now let's learn how to create a function that utilizes the preceding signature and returns a tensor with type tf.float32
, that is, the max pooled output tensor:
import tensorflow as tf def maxpool2d(x, k=2): return tf.nn.max_pool(x, ksize=[1, k, k, 1], strides=[1, k, k, 1], padding='SAME')
In the preceding code segment, the parameters can be described as follows:
value
: This is a 4D tensor offloat32
elements...