I am trying to follow the following tutorial accessible with this link.
Under the 3rd Heading, "3. Visualize the Activation Maps for Each Filter", we can see the following function:
def apply_filter(img, index, filter_list, ax):
# set the weights of the filter in the convolutional layer to filter_list[i]
model.layers[0].set_weights([np.reshape(filter_list[i], (4,4,1,1)), np.array([0])])
# plot the corresponding activation map
ax.imshow(np.squeeze(model.predict(np.reshape(img, (1, img.shape[0], img.shape[1], 1)))), cmap='gray')
I understood what they are trying to do. They are applying the filters and trying to show the output after that. But, what I don't understand is the following line:
model.layers[0].set_weights([np.reshape(filter_list[i], (4,4,1,1)), np.array([0])])
What does it mean to assign weights here and also, why are they reshaping the filter which is of 4*4
to 4*4*1*1
?