sicara / tf-explain

Interpretability Methods for tf.keras models with Tensorflow 2.x
https://tf-explain.readthedocs.io
MIT License
1.02k stars 111 forks source link

Error in transform_to_normalized_grayscale #121

Open matheushent opened 4 years ago

matheushent commented 4 years ago

I have been debugging some functions and I noticed that transform_to_normalized_grayscale defined in tf_explain/utils/image doesn't return a 4D tensor as described in function.

I think the channels axis is being totally disconsidered. So, the keepdims argument inside reduce_sum must be set to True, furthermore tf.reduce_sum would be properly changed by tf.math.reduce_sum.

In other words:

grayscale_tensor = tf.math.reduce_sum(tensor, axis=-1, keepdims=True) instead of grayscale_tensor = tf.reduce_sum(tensor, axis=-1)

matheushent commented 4 years ago

I am a little bit lost about what exactly transform_to_normalized_grayscale does. The output of this function just gives me completely black images instead of gray scale images.

RaphaelMeudec commented 4 years ago

@matheushent Totally agree with you. This function does too much things and should be split into multiple ones. At the moment:

Hope it helps a bit, will try to make it cleaner