# Why do we get a three-dimensional output after a convolutional layer?

In a convolutional neural network, when we apply the convolution on a $$5 \times 5$$ image with $$3 \times 3$$ kernel, with stride $$1$$, we should get only one $$4 \times 4$$ as output. In most of the CNN tutorials, we are having $$4 \times 4 \times m$$ as output. I don't know how we are getting a three-dimensional output and I don't know how we need to calculate $$m$$. How is $$m$$ determined? Why do we get a three-dimensional output after a convolutional layer?

If you have a $$h_i \times w_i \times d_i$$ input, where $$h_i, w_i$$ and $$d_i$$ respectively refer to the height, width and depth of the input, then we usually apply $$m$$ $$h_k \times w_k \times d_i$$ kernels (or filters) to this input (with the appropriate stride and padding), where $$m$$ is usually a hyper-parameter. So, after the application of $$m$$ kernels, you will obtain $$m$$ $$h_o \times w_o \times 1$$ so-called feature maps (also known as activation maps), which are usually concatenated along the depth dimension, hence your output will have a depth of $$m$$ (given that the application of a kernel to the input usually produces a two-dimensional output). For this reason, the output is usually referred to as output volume.