deel-ai / oodeel

Simple, compact, and hackable post-hoc deep OOD detection for already trained tensorflow or pytorch image classifiers.
https://deel-ai.github.io/oodeel/
MIT License
52 stars 2 forks source link

Add feature extractor for torch #2

Closed paulnovello closed 1 year ago

paulnovello commented 1 year ago

Translate KerasFeatureExtractor into TorchFeatureExtractor. It is unnecessary to translate the methods gradient_pred, gradient_index, and gradient_full for now because they are likely to be deprecated soon.

The class should:

Matt3164 commented 1 year ago

For the interface, I have no use of

output_activation: str = None
flatten: bool = False
batch_size: int = 256

Can I remove them? Or should I keep them unused with default values?

Matt3164 commented 1 year ago

For the output type of the predict method, is it better to output the default torch.Tensor or output a np.ndarray which could be more easy to use with methods implemented is Tensorflow?

paulnovello commented 1 year ago

I seems like these parameters are used:

For the predict method, it is indeed better to output a np.ndarray

Matt3164 commented 1 year ago

Just a simple check, the output of feature extractor is the output of the given output layer (specified with output_layers_id) and not the input right.

I am not familiar with the default behavior of keras.

paulnovello commented 1 year ago

Yes. Notice that the output of the whole network is also returned self.output_layers.append(model.output) l.86 of feature_extractor.py.