albermax / innvestigate

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

Exception: No softmax found. #270

Closed Yung-zi closed 2 years ago

Yung-zi commented 2 years ago

the bug

model = vgg16.VGG16() model = innvestigate.utils.model_wo_softmax(model)

My effort

I tried this after but it also failed. model = innvestigate.utils.keras.graph.model_wo_softmax(model)

I run this code in Colab notebook. Successfully installed innvestigate-1.0.9 keras-2.2.4 keras-applications-1.0.8

adrhill commented 2 years ago

Hi @Yung-zi,

I wasn't able to replicate your issue using iNNvestigate 1.0.9 and Keras 2.2.4. Are you using the VGG16 model from keras.applications?

import keras.applications.vgg16 as vgg16
import innvestigate

model = vgg16.VGG16()
print(model.layers[-1].activation)  # <function softmax at 0x1420d90d0>

model = innvestigate.utils.model_wo_softmax(model)
print(model.layers[-1].activation)  # <function linear at 0x1420d9620>