2. Let me try to explain this better. If we want to optimize the inputs to the first layer, these inputs are actual RGB images. So what you're doing in line 35 is correct:
input_img_data = np.random.random((1, 3, intermediate_dim[0], intermediate_dim[1]))
but in the next layer, the inputs have more channels than 3. So you should be optimizing images of the shape the layer expects (replacing 3 with the number of channels of that layer). If you do it like that, then the image you want to visualize - the image that excites the outputs of an intermediate layer the most - will have more channels than 3, and therefore it's not clear whether we should pick arbitrary triplets of channels to use as RGB channels, or if we should visualize each channel (each input feature map) individually, in which case it would have no color.I guess my question should be: when you show optimized inputs to the second or third VGG layers where does the color information comes from? Also, you probably shouldn't call them "filters", because the filters in this context are the actual convolutional layer weight kernels, and are 3x3 in size (each filter).