ntedgi/node-efficientnet

This is not how you deal with logits

Closed this issue · 2 comments

Describe the bug
This algorithm produces the wrong outputs: https://github.com/ntedgi/node-efficientnet/blob/main/src/EfficientNetResult.ts#L26

To Reproduce
Steps to reproduce the behavior:

  1. Set topK = 3
  2. Let code predict something
  3. All three labels are approximately 33%

Expected behavior
Get original model probabilities.

Screenshots
No.

Additional context
Google's mobilenet implementation illustrates how to deal with logits: https://github.com/tensorflow/tfjs-models/tree/master/mobilenet

which EfficientNetCheckPoint did you use?
can you attach your implementation please ?
or use npm run example and change topK and attchce output

this is the output I am getting for the samples dir with topK=3
[ { label: 'honeycomb', precision: 39.57828750014812 }, { label: 'matchstick', precision: 30.304513760285996 }, { label: 'candle, taper, wax light', precision: 30.117198739565886 } ] [ { label: 'giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca', precision: 56.48649911640021 }, { label: 'French bulldog', precision: 24.4534070988847 }, { label: 'soccer ball', precision: 19.060093784715082 } ] [ { label: 'sports car, sport car', precision: 88.49501012956064 }, { label: 'racer, race car, racing car', precision: 7.0412236667543775 }, { label: 'car wheel', precision: 4.463766203684982 } ]

Ah, this may be due to me using Efficientnet v2 which churns out logits.