concept depth in category deep learning

This is an excerpt from Manning's book Deep Learning for Vision Systems.
To recap - computers see an image as matrices. Grayscale images have one channel (gray), thus we can represent grayscale images in the 2D matrix, where each element represents the intensity of brightness in that particular pixel. Remember, 0 means black and 255 means white. Grayscale images have one channel, whereas color images have three channels RGB (red, green, blue). We can represent color images in the 3D matrix where the depth will be 3.
from keras.models import Sequential from keras.layers import Conv2D, MaxPooling2D, Flatten, Dense, Dropout # build the model object model = Sequential() # CONV_1: add CONV layer with RELU activation and depth = 32 kernels model.add(Conv2D(32, kernel_size=(3, 3), stride=1, padding='same', activation='relu', input_shape=(28,28,1))) # POOL_1: downsample the image to choose the best features model.add(MaxPooling2D(pool_size=(2, 2))) # CONV_2: here we increase the depth to 64 model.add(Conv2D(64, (3, 3), stride=1, padding='same', activation='relu')) # POOL_2: more downsampling model.add(MaxPooling2D(pool_size=(2, 2))) # flatten since too many dimensions, we only want a classification output model.add(Flatten()) # FC_1: fully connected to get all relevant data model.add(Dense(64, activation='relu')) # FC_2: output a softmax to squash the matrix into output probabilities for the 10 classes model.add(Dense(10, activation='softmax')) # print model architecture summary model.summary()
Color images on the other hand are interpreted by the computer as a 3D matrix with height, width and depth . In the case of RGB images (reg, green, and blue) the depth is three. One channel for each color. For example, a colored 28x28 image will be seen by the computer as a 28x28x3 matrix. Think of this as a stack of three 2D matrices. One for Red, one for Green and one for Blue channel of the image. Each one of the three matrices represent the value of intensity of this color. And when they are stacked together, they create a complete color image.
Figure 3.46
![]()
For generalization, we represent images as a 3D array = (height x width x depth). For grayscale images the depth = 1 and for color images the depth = 3.

This is an excerpt from Manning's book Deep Learning with PyTorch.
An image is represented as a collection of scalars arranged in a regular grid with a height and a width (in pixels). We might have a single scalar per grid point (the pixel), which would be represented as a grayscale image; or multiple scalars per grid point, which would typically represent different colors, as we saw in the previous chapter, or different features like depth from a depth camera.
Scalars representing values at individual pixels are often encoded using 8-bit integers, as in consumer cameras. In medical, scientific, and industrial applications, it is not unusual to find higher numerical precision, such as 12-bit or 16-bit. This allows a wider range or increased sensitivity in cases where the pixel encodes information about a physical property, like bone density, temperature, or depth.
Earlier, we talked about width as the first dimension to act on in order to make a model larger and, in a way, more capable. The second fundamental dimension is obviously depth. Since this is a deep learning book, depth is something we’re supposedly into. After all, deeper models are always better than shallow ones, aren’t they? Well, it depends. With depth, the complexity of the function the network is able to approximate generally increases. In regard to computer vision, a shallower network could identify a person’s shape in a photo, whereas a deeper network could identify the person, the face on their top half, and the mouth within the face. Depth allows a model to deal with hierarchical information when we need to understand the context in order to say something about some input.
There’s another way to think about depth: increasing depth is related to increasing the length of the sequence of operations that the network will be able to perform when processing input. This view--of a deep network that performs sequential operations to carry out a task--is likely fascinating to software developers who are used to thinking about algorithms as sequences of operations like “find the person’s boundaries, look for the head on top of the boundaries, look for the mouth within the head.”