I trained a 1 layer CNN model with 128 3x3 kernels. I evaluated the model with a prescribed test data set and now I want to evaluate the performance of this model where we only consider select kernels (meaning other kernels are set to 0). My question is, how exactly can I go into the model and set these unwanted kernels to 0? Any help would be greatly appreciated.
$\begingroup$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. $\endgroup$– Community BotOct 19, 2022 at 3:11
You could manually create a copy of the model, reset some of the weights to zero and do the experiment that way.
But an easier way is to pass two inputs to the model: the image, and a kernel mask. Assuming the convolution layer uses ReLU, it is natural to multiply its output with the mask element-wise before passing it to subsequent layers. The mask would have values of all one when training, but during the experiment you could set the selected of the 128 values to zero. This way you don't need to modify the weights ad-hoc.
Actually this is very similar to what dropout does, except you are doing the dropout at evaluation stage rather than during training.
$\begingroup$ Thank you for your response. I indeed have a copy of my model, but I do not know how to reset such weights to 0. I tried looking at the tensorflow documentation, but I haven't been able to find anything relevant. If you happen to know how or can direct me to the appropriate resource, I would appreciate it very much. $\endgroup$ Oct 19, 2022 at 21:52