kundajelab / deeplift

Public facing deeplift repo
MIT License
818 stars 162 forks source link

Support residual network architecture #59

Open Zireae1 opened 6 years ago

Zireae1 commented 6 years ago

Hi Avanti and others,

Thank you for the great tool! I would like to use your package to compute the feature contribution for the residual network, however it seems that this type of layers is not supported currently. Could you please adapt your tool to handle this type of networks?

My network architecture looks like this: ` import keras as ke PS = 6212
DR = 0.2

inputs = Input(shape=(PS,))

x = Dense(2000, activation='relu')(inputs)

x = Dense(1000, activation='relu')(x) x = Dropout(DR)(x)

y = Dense(1000, activation='relu')(x)

z = ke.layers.add([x,y]) z = Dropout(DR)(z)

y = Dense(1000, activation='relu')(z)

x = ke.layers.add([z,y]) x = Dropout(DR)(x)

y = Dense(1000, activation='relu')(x)

z = ke.layers.add([x,y]) z = Dropout(DR)(z)

y = Dense(1000, activation='relu')(z)

x = ke.layers.add([z,y]) x = Dropout(DR)(x)

x = Dense(500, activation='relu')(x) x = Dropout(DR)(x)

x = Dense(250, activation='relu')(x) x = Dropout(DR)(x)

x = Dense(125, activation='relu')(x) x = Dropout(DR)(x)

x = Dense(62, activation='relu')(x) x = Dropout(DR)(x)

x = Dense(30, activation='relu')(x) x = Dropout(DR)(x)

outputs = Dense(2, activation='softmax')(x)

model = Model(inputs=inputs, outputs=outputs)

model.summary()

model.compile(loss='categorical_crossentropy', optimizer=SGD(lr=0.001, momentum=0.9), metrics=['accuracy']) ` Thanks for help.

AvantiShri commented 6 years ago

Sorry I haven't gotten to this yet. It's on the to-do, I've just been sidetracked by other projects. In the meantime, if this is urgent for you, you could take a look at the DeepLIFT implementation in the DeepExplain repository - it only supports the Rescale rule of DeepLIFT (so it may not perform as well), but because it is implemented by overriding tensorflow gradient operators, it should support most architectures: https://github.com/kundajelab/deeplift#how-does-the-implementation-in-this-repository-compare-with-the-implementation-in-ancona-et-al-iclr-2018