You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running any LRP analyzer, I get tensorflow warnings in the format of something like: 2023-11-22 10:49:33.032371: W tensorflow/c/c_api.cc:305] Operation '{name:'mul_1355/x' id:43796 op device:{requested: '', assigned: ''} def:{{{node mul_1355/x}} = Const[_has_manual_control_dependencies=true, dtype=DT_FLOAT, value=Tensor<type: float shape: [] values: 1e-07>]()}}' was changed by setting attribute after it was run by a session. This mutation will have no effect, and will trigger an error in the future. Either don't modify nodes after running them or create a new session.
Being printed at what looks to be every single layer in the EfficientNet model I'm using. It also runs very slowly, taking about 15 minutes (longer if I use the sequential presets) to analyze the model. Is this runtime normal due to the size of the network? Can I safely ignore these warnings or is something actually wrong?
Steps to reproduce the bug
NOTE: I had to implement juliowissing-iis's fix here for this code block to run without errors.
importtensorflowastfimporttensorflow.keras.utilsaskuimportnumpyasnpimportinnvestigateasinnfromtensorflow.keras.applicationsimportEfficientNetB5importtimetf.compat.v1.disable_eager_execution()
# create EfficientNet B5 model with imagenet weightsmodel=EfficientNetB5(weights='imagenet')
# Read in dataimg=ku.load_img('img.jpg',target_size= (456,456))
# Conver1 to numpy arrayimg_arr=ku.img_to_array(img)
# Add in extra 1st dimimg_CNN=np.array([img_arr])
# Remove last softmax layer (required for INNvestigate)model_wo_softmax=inn.model_wo_softmax(model)
# Create LRP epsilon analyzeranalyzer=inn.create_analyzer("lrp.epsilon", model_wo_softmax,**{'epsilon':1})
# Analyze input imaget0=time.time()
a=analyzer.analyze(img_CNN)
t1=time.time()
total_time=t1-t0print(f'Anaylzer took {total_time} seconds')
Expected behavior
Minimal mutation warnings and a code that doesn't take 15 minutes to run.
Platform information
OS: Mac OSX 13.6.1 (this behavior also occurs on CentOS 7)
Python version: 3.10.13
iNNvestigate version: 2.1.2
TensorFlow version: 2.14.0
The text was updated successfully, but these errors were encountered:
It is because of the tf.compat.v1.disable_eager_execution(). I am working with EfficientNetV2B0 and the analyze method takes to much time to execute.
Even worst on my side, using the following code: inn.create_analyzer("lrp.epsilon", model_wo_softmax,**{'epsilon':1}) returns an error related with LRP only supports convolutional layers (EfficientNetV2B0 has DepthwiseConv2D layers).
I could execute LRP analysis with the following code:
from innvestigate.analyzer import LRP
analyzer = LRP(model_wo_softmax, rule="Epsilon", **{'reverse_verbose': True})
But I had to do a change in the library code (file: relevance_analyzer.py; line:188):
the original code is getting this value from config["axis"], but in EfficientnetV2B0 the value of config["axis"] is a list (i.e. 'axis': ListWrapper([3])).
Of course, modifying the library code is not a good idea.
Describe the bug
Running any LRP analyzer, I get tensorflow warnings in the format of something like:
2023-11-22 10:49:33.032371: W tensorflow/c/c_api.cc:305] Operation '{name:'mul_1355/x' id:43796 op device:{requested: '', assigned: ''} def:{{{node mul_1355/x}} = Const[_has_manual_control_dependencies=true, dtype=DT_FLOAT, value=Tensor<type: float shape: [] values: 1e-07>]()}}' was changed by setting attribute after it was run by a session. This mutation will have no effect, and will trigger an error in the future. Either don't modify nodes after running them or create a new session.
Being printed at what looks to be every single layer in the EfficientNet model I'm using. It also runs very slowly, taking about 15 minutes (longer if I use the sequential presets) to analyze the model. Is this runtime normal due to the size of the network? Can I safely ignore these warnings or is something actually wrong?
Steps to reproduce the bug
NOTE: I had to implement juliowissing-iis's fix here for this code block to run without errors.
Expected behavior
Minimal mutation warnings and a code that doesn't take 15 minutes to run.
Platform information
The text was updated successfully, but these errors were encountered: