albermax / innvestigate

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

Error with Collect Layers for functional models for TF 2.1 #253

Closed adityajain93 closed 2 years ago

adityajain93 commented 3 years ago
def collect_layers(container):
    for layer in container.layers:
        # assert layer not in ret
        if layer not in ret:
            ret.append(layer)
        if kchecks.is_network(layer):
            collect_layers(layer)
collect_layers(model)

If we have a functional keras model with shared layers. Something like an autoencoder in which the input is shared with the encoder model and the autoencoder, the assert statement fails when trying to explain the autoencoder.

Any ideas on how to get around it!

I'm trying to explain a neural net with LRP Epsilon in the updates_to_tf2.0 branch

nboutry commented 3 years ago

Hi,

Can someone please tell me how I can unsubscribe ?

Best, N.B.

Le 11 juin 2021 à 16:17, adityajain93 @.***> a écrit :

def collect_layers(container): for layer in container.layers:

assert layer not in ret

    if layer not in ret:
        ret.append(layer)
    if kchecks.is_network(layer):
        collect_layers(layer)

collect_layers(model) If we have a functional keras model with shared layers. Something like an autoencoder in which the input is shared with the encoder model and the autoencoder, the assert statement fails when trying to explain the autoencoder.

Any ideas on how to get around it!

I'm trying to explain a neural net with LRP Epsilon in the updates_to_tf2.0 branch

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/albermax/innvestigate/issues/253, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALN5XE5PGX54PQ4FF5PWQ33TSILHFANCNFSM46Q2U4GQ.

adrhill commented 2 years ago

Hi @adityajain93,

we just released iNNvestigate 2.0 with support for TensorFlow 2! Please try it out and let me know if this fixes your issue. :)