Skip to content

Different shapes from running methods of tf.xplain.core #187

@annahedstroem

Description

@annahedstroem

Problem

The output shape of explanations differ for GradCAM (and OcclusionSensitivity) and e.g., VanillaGradient, where GradCAM also includes the channels.

Implementation

While the syntax is the same:

explainer = tf_explain.core.grad_cam.GradCAM()
        explanation = (
            np.array(
                list(
                    map(
                        lambda x, y: explainer.explain(
                            ([x], None), model, y, **method_kwargs
                        ),
                        inputs,
                        targets,
                    )
                ),
                dtype=float,
            )
            / 255
        )

=== {"shape": (nr_samples, img_size, img_size, nr_channels)},

vs

explainer = tf_explain.core.vanilla_gradients.VanillaGradients()
        explanation = (
            np.array(
                list(
                    map(
                        lambda x, y: explainer.explain(
                            ([x], None), model, y, **method_kwargs
                        ),
                        inputs,
                        targets,
                    )
                ),
                dtype=float,
            )
            / 255
        )

=== {"shape": (nr_samples, img_size, img_size)},

Thank you!

Activity

annahedstroem

annahedstroem commented on Feb 22, 2023

@annahedstroem
Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @annahedstroem

        Issue actions

          Different shapes from running methods of tf.xplain.core · Issue #187 · sicara/tf-explain