Implementing CNN with tensorflow
<p>I'm new in convolutional neural networks and in Tensorflow and I need to implement a conv layer with further parameters:</p>

<p>Conv. layer1: filter=11, channel=64, stride=4, Relu.</p>

<p>The API is following:</p>

<pre><code>tf.nn.conv2d(input, filter, strides, padding, use_cudnn_on_gpu=None, data_format=None, name=None)
</code></pre>

<p>I understand, what is stride and that it should be [1, 4, 4, 1] in my case. But I do not understand, how should I pass a filter parameter and padding.
Could someone help with it?</p>

<p>At first, you need to create a filter variable:</p>

<pre><code>W = tf.truncated_normal(shape = [11, 11, 3, 64], stddev = 0.1)
</code></pre>

<p>First two fields of shape parameter stand for filter size, third for the number of input channels (I guess your images have 3 channels) and fourth for the number of output channels.</p>

<p>Now output of convolutional layer could be computed as follows:</p>

<p><code>conv1 = tf.nn.conv2d(input, W, strides = [1, 4, 4, 1], padding = 'SAME')</code>, where <code>padding = 'SAME'</code> stands for zero padding and therefore size of the image remains the same, input should have size [batch, size1, size2, 3].</p>

<p>ReLU application is pretty straightforward:</p>

<pre><code>conv1 = tf.nn.relu(conv1)
</code></pre>

python neural-network tensorflow convolution conv-neural-network