Closed tydickinson29 closed 1 year ago
Hello, I have the same error. Did you find any solution? Thanks.
Hi, I ran into this same problem, but passed it by changing line 119 of analyzer/network_base.py from
model_output = klayers.Flatten()(model_output)
to
model_output = klayers.Flatten()(model.outputs[0])
I think the model_output: list[Tensor]
may be the problem (earlier in the prepare_model function).
However, there are still problems further in that I have not yet worked out. Hope this helps.
Thanks @michaelmontalbano for the comment! It is indeed a shape issue. I simply made a new keras.Model
by adding a reshape layer to my model:
model = keras.models.load_model(path_to_saved_model)
orig_shape = model.output_shape
new_shape = orig_shape[1]*orig_shape[2]
reshp = tf.keras.layers.Reshape((new_shape,), input_shape=orig_shape)(model.layers[-1].output)
new_model = keras.Model(inputs=model.inputs, outputs=[reshp])
lrp = innvestigate.analyzer.relevance_based.relevance_analyzer.LRPZ(new_model)
Now, running lrp.analyze()
works as expected!
Note: I also ended up adding tf.compat.v1.disable_eager_execution()
at the beginning of the program.
Hi! I would like to use your package to explain my CNN, specifically using the LRP and input*gradient methods. The architecture is based on a u-net and can be seen here:
However, I get the following error:
I am slightly confused, especially considering my architecture does not have any flatten layers to begin with. Any insights into the origin of the error and anything I can to do alleviate the situation is greatly appreciated. Thank you!
Platform information