ntedgi / node-efficientnet

tensorflowJS implementation of EfficientNet 🚀
https://www.npmjs.com/package/node-efficientnet
MIT License
257 stars 37 forks source link

This is not how you deal with logits #60

Closed marcelklehr closed 3 years ago

marcelklehr commented 3 years ago

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

ntedgi commented 3 years ago

which EfficientNetCheckPoint did you use? can you attach your implementation please ? or use npm run exampleand 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 } ]

marcelklehr commented 3 years ago

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