# Understand the Shape of Tensor Returned by tf.nn.conv2d() – TensorFlow Tutorial

By | August 9, 2020

TensorFlow tf.nn.conv2d() function can build a convolution network. Here is a tutorial:

Understand tf.nn.conv2d(): Compute a 2-D Convolution in TensorFlow

However, how about the shape of returned tensor? In this tutorial, we will discuss this topic.

We have known the shape of tensor returned by tf.nn.conv2d()  is: [batch, out_height, out_width, out_channels ]out_height and out_width is determinded by filterstridespadding and dilations.

If dilations=[1, 1, 1, 1], out_height and out_width can be computed as following.

out_height = ceil(float(in_height) / float(strides[1]))

out_width = ceil(float(in_width) / float(strides[2]))

out_height = ceil(float(in_height - filter_height + 1) / float(strides[1]))
out_width = ceil(float(in_width - filter_width + 1) / float(strides[2]))