albermax / innvestigate

A toolbox to iNNvestigate neural networks' predictions!
Other
1.25k stars 233 forks source link

Output shape of `analyze` does not match input shape #226

Open daviddliu opened 3 years ago

daviddliu commented 3 years ago

On most recent commit of updates_towards_tf2.0 branch, the output of the analyzer doesn't seem to match my input:

 # Add an explicit input layer
    input_layer = KL.Input(shape=input_shape)
    x = model.layers[0](input_layer)

    for layer in model.layers[1:]:
        x = layer(x)

    new_model = tf.keras.models.Model(input_layer, x)
    analyzer = innvestigate.create_analyzer('lrp.epsilon', new_model)

    lrp_ims = analyzer.analyze(input_images)['input_3'][0]

Here, input_images is of shape (1000, 200, 100, 1), as it is a tensor of 1000 images of size 200x100. However, lrp_ims is of shape (1000, 1, 100, 1). It should clearly still be (1000, 200, 100, 1). I'm not sure what happens to the second axis' shape here?

This is not an issue on prior commit 5c67fd5, where the output of analyzer.analyze was a list, not a dictionary.

daviddliu commented 3 years ago

Furthermore, the output shape isn't correct if I add a batch axis, or if I do the same thing with individual images. I guess I am confused what the input tensor to analyze should be? Excited to use this package!