tf-explain
tf-explain copied to clipboard
Subclassing API
The current version of tf-explain does not support subclassing API because of the way subgraphs are created.
See: https://stackoverflow.com/questions/52826134/keras-model-subclassing-examples
Hi! Thanks of all thank you for this great library! Is this functionality high on your priority list?
Hi! I'm on holiday for a few days, but plan to tackle this as soon as I get back. There's an open issue on Tensorflow to help fix this
Excellent, thank you!
@dtransposed looks like getting support for subclassing API is going to be harder than expected: https://github.com/tensorflow/tensorflow/issues/30955#issuecomment-520291616
Yes, I have tried to hack your code to use it with my models built using subclassing API and failed. It's a pity there is no way to "translate" subclassing model into functional one so far...
@RaphaelMeudec is there any update on this issue? A workaround is also fine ...
@leeor-langer No fix as of today. Best option is to define subclass layer with strict minimum operations and use it in a sequential/functional model, instead of defining the whole model in a subclass layer.
For example:
class MySpecialPadding(tf.keras.Layer):
def call(self, inputs, *args, **kwargs):
x = tf.pad(inputs, my_padding)
return x
model = tf.keras.Model([
tf.keras.layers.Conv2D(..),
MySpecialPadding(),
])
is there an update on the problem ?