alibi-detect icon indicating copy to clipboard operation
alibi-detect copied to clipboard

Remove `nn.Sequential` and `tf.keras.Sequential` typings

Open ascillitoe opened this issue 2 years ago • 3 comments

In a number of places we have type hints (and potentially type checks) for torch models like:

model: Union[nn.Sequential, nn.Module]

However, nn.Sequential is a sub-class of nn.Module. Therefore we can remove the nn.Sequential's. This needs to be done in numerous places.

Likewise, the same should be done for tf.keras.Sequential, which is a subclass of tf.keras.Model.

ascillitoe avatar Oct 27 '22 13:10 ascillitoe

I'm not sure but I think historically in some cases there has been a genuine restriction needed to a subset of models that are sequential (e.g. do we do layer indexing by integers anywhere?), although I don't know of any examples off the top of my head @arnaudvl

jklaise avatar Oct 27 '22 13:10 jklaise

That's a good point. Would be good to clarify before we do this.

ascillitoe avatar Oct 28 '22 08:10 ascillitoe

Note: This is a duplicate of https://github.com/SeldonIO/alibi-detect/issues/239. Closing that one since this issue also includes PyTorch.

ascillitoe avatar Feb 15 '23 11:02 ascillitoe