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

Logits as attribute of the FeatureExtractor? #73

Closed paulnovello closed 1 year ago

paulnovello commented 1 year ago

We should think about that because right now, in _score_tensor, we have to gather the logits after a forward and return it at the end of the method:

      _, logits = self.feature_extractor.predict_tensor(inputs)
      pred = logits
      pred = self.op.convert_to_numpy(pred)
      scores = -np.max(pred, axis=1)
      logits = self.op.convert_to_numpy(logits)
      return scores, logits

Also, in many baselines we need to perform a forward, e.g. in .fit, without using the logits. Hence, automatically setting an attribute FeatureExtractor.logits when calling .predict could make the code more logical and encapsulated since we would be able not to bother with getting the logits or not, and only use them when needed.