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

Make the feature extractor output layer a required argument of oodmodel #30

Closed paulnovello closed 1 year ago

paulnovello commented 1 year ago

Currently, output_layers_id is an Optional argument with a default value often chosen as [-2] to enforce the feature extractor to project onto the penultimate layer. However, often, the layer identified as -2 can be something else. For instance, -1 can be a softmax layer and -2 the linear layer, in which case layer[-2] is not the penultimate layer.

Proposed solution: make this argument non optional with a link to a doc tutorial showing how to properly fill this argument as an error message thrown by

assert output_layers_id is not None, "error msg with link"

[Additional suggestion, YP] : In torch, when the model is not a Sequential and the output layer id is an integer, send a warning message recommanding the user to use a string layer id instead.