concept input image in category deep learning

This is an excerpt from Manning's book Deep Learning for Vision Systems.
It is important to call out that the image above reflects features extracted from just one motorcycle. A very important characteristic of a feature is repeatability. As in the feature should be able to detect the motorcycles in general not just this specific one. So, in real world problems, the feature will not be an exact copy of the piece in the input image.
Here is how we flatten the input image in Keras:
# same as before, we start with importing keras library from keras.models import Sequential # here we import a layer called Flatten to convert the image matrix into a vector from keras.layers import Flatten # define the model model = Sequential() # add the flatten layer - also known as the input layer model.add( Flatten(input_shape = (28,28) )Alright, the Flatten layer in Keras takes care of this process for us. It takes the 2D image matrix input and converts it to a 1D vector. Note that the Flatten layer must be supplied a parameter value of the shape of the input image. Now the image is ready to be fed to the neural network. What’s next? Hidden layers.
For example, suppose the input image is 28x28 (like in the MNIST dataset). When we add a CONV_1 layer (with filters = 4, stride = 1, padding = same), the output will be the same width and height dimensions but with depth = 4 (28x28x4). Now we add CONV_2 layer with the same hyperparameters but more filters = 12, we get a deeper output = 28x28x12.
Figure 7.12: Fast R-CNN architecture. An input image is the input of a fully convolutional network. Each ROI
![]()

This is an excerpt from Manning's book Deep Learning with JavaScript: Neural networks in TensorFlow.js.
At least on a superficial level, this pattern is somewhat similar to the general organization of artificial neural networks (simply called neural networks in the world of computing, where there is little risk of confusion), in which the data is processed in multiple separable stages, aptly named layers. These layers are usually stacked on top of each other, with connections only between adjacent ones. Figure 1.5 shows a simple (artificial) neural network with four layers. The input data (an image, in this case) feeds into the first layer (on the left side of the figure), then flows sequentially from one layer to the next. Each layer applies a new transformation on the representation of the data. As the data flows through the layers, the representation becomes increasingly different from the original and gets closer and closer to the goal of the neural network—namely, applying a correct label to the input image. The last layer (on the right side of the figure) emits the neural network’s final output, which is the result of the image-classification task.
Visualizing convnet filters by finding input images that maximally activate them—This is useful for understanding what visual pattern or concept each filter is sensitive to. Visualizing heatmaps of class activation in an input image—This helps in understanding which parts of an input image play the most important role in causing the convnet to generate the final classification result, which can also be useful for interpreting how a convnet reaches its output and for “debugging” incorrect outputs.
Once we have this gradient function, we invoke it in a loop. In each iteration, we use the gradient value it returns to update the input image. An important nonobvious trick here is to normalize the gradient values before adding them to the input image, which ensures that the update in each iteration has a consistent magnitude:
const norm = tf.sqrt(tf.mean(tf.square(grads))).add(EPSILON); return grads.div(norm);This iterative update to the input image is performed 80 times, giving us the results shown in figure 7.10.
The last post-training convnet visualization technique we will introduce is the class activation map (CAM) algorithm. The question that CAM aims to answer is “which parts of the input image play the most important roles in causing the convnet to output its top classification decision?” For instance, when the cat.jpg image was passed to the VGG16 network, we got a top class of “Egyptian cat” with a probability score of 0.89. But by looking at just the image input and the classification output, we can’t tell which parts of the image are important for this decision. Surely some parts of the image (such as the cat’s head) must have played a greater role than other parts (for example, the white background). But is there an objective way to quantify this for any input image?
The answer is yes! There are multiple ways of doing this, and CAM is one of them.[8] Given an input image and a classification result from a convnet, CAM gives you a heat map that assigns importance scores to different parts of the image. Figure 7.11 shows such CAM-generated heat maps overlaid on top of three input images: a cat, an owl, and two elephants. In the cat result, we see that the outline of the cat’s head has the highest values in the heat map. We can make the post hoc observation that this is because the outline reveals the shape of the animal’s head, which is a distinctive feature for a cat. The heat map for the owl image also meets our expectation because it highlights the head and wing of the animal. The result from the image with two elephants is interesting because the image differs from the other two images in that it contains two individual animals instead of one. The heat map generated by CAM assigns high importance scores to the head regions of both elephants in the image. There is a clear tendency for the heat map to focus on the trunks and ears of the animals, which may reflect the fact that the length of the trunk and the size of the ears are important in telling African elephants (the top class from the network) apart from Indian elephants (the third class from the network).