Zeta11
Zeta11

Reputation: 881

How is a filter assigned with feature in CNN? (or is it assigned?)

Lets say the first conv layer has 32 filters of size 5x5 with stride of 1.

model.add(Conv2D(32, (5, 5), input_shape=input_shape))

Lets say the image is of size 32x32x3(channesl). So when a filter convolves with a part of an image, is it already looking for a specific feature? I understand that the filter matrix is initialized with random numbers. But do they already have a sort of purpose to what they are looking for? Could you explain how features are being detected in CNN?

Upvotes: 0

Views: 152

Answers (1)

Giang Nguyen
Giang Nguyen

Reputation: 498

The goal of a convolutional layer is filtering. As we move over an image we effectively check for patterns in that section of the image. This works because of filters, stacks of weights represented as a vector, which are multiplied by the values outputed by the convolution.When training an image, these weights change, and so when it is time to evaluate an image, these weights return high values if it thinks it is seeing a pattern it has seen before. The combinations of high weights from various filters let the network predict the content of an image.

So, when a filter convolves with a part of an image, at first, it doesn't know it is feature or not, by training and changing weights, the filters are adaptive to the features in images so that the Loss function should be minimum with the ground truth. The reason for initialization is just we will change weights so that the predicted value will be as closest as possible to the given label.

Upvotes: 1

Related Questions