strange behavior when quantizing a model.
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- python, tensorflow
- Ambito
- machine-learning
Direzione di ricerca
Esamina tensorflow_model_optimization/python/core/quantization/keras/quantize.py alle righe indicate, concentrandoti su come requires_output_quantize viene popolato e utilizzato per i layer subclassed di tf.Keras.Model. Riproduci il comportamento con TensorFlow 2.14 e tfmot 0.7.5 utilizzando un layer concatenate non annotato. Il lavoro è completato quando si determina se il comportamento è previsto e lo si documenta o corregge con una validazione di supporto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hi all,
I was trying to quantize my model but something strange popped up.
I am using TensorFlow v2.14 and tfmot v0.7.5
I have a sub-classed tf.Keras.Model. It contains some custom layers and other standard layers such as concatenate, activation, etc..
I just want some specific layers to be quantized. For instance, I do not want concatenate to be quantized and 2 other layers. For that, I did not annotate them, so they are not an instance of QuantizeAnnotate.
But strangely, I see that concatenate is an instance of QuantizeWrapperV2. Although, I can also see it is not an instance of QuantizeAnnotate in my cloned function.
So, I do not understand why here : https://github.com/tensorflow/model-optimization/blob/e38d886935c9e2004f72522bf11573d43f46b383/tensorflow_model_optimization/python/core/quantization/keras/quantize.py#L384 we add to requires_output_quantize a layer that it is not an instance of QuantizeAnnotate rather then to check on isinstance as the name suggest? My layers that have not been annotated should be returned from here : https://github.com/tensorflow/model-optimization/blob/e38d886935c9e2004f72522bf11573d43f46b383/tensorflow_model_optimization/python/core/quantization/keras/quantize.py#L377 but during debug, I see that concatenate and other layers, that were not annotated, were added to requires_output_quantize. I believe, this should be wrong.
Now, if we go to this - https://github.com/tensorflow/model-optimization/blob/e38d886935c9e2004f72522bf11573d43f46b383/tensorflow_model_optimization/python/core/quantization/keras/quantize.py#L418C28-L418C52 we can see that if the layer is not in requires_output_quantize and not in layer_quantize_map then we will just retun the layer. But requires_output_quantize holds layers that do NOT need to be quantized from what I am seeing and what this : https://github.com/tensorflow/model-optimization/blob/e38d886935c9e2004f72522bf11573d43f46b383/tensorflow_model_optimization/python/core/quantization/keras/quantize.py#L384 is suggesting.
So I would expect layer.name not in requires_output_quantize to be removed in this if statement:
https://github.com/tensorflow/model-optimization/blob/e38d886935c9e2004f72522bf11573d43f46b383/tensorflow_model_optimization/python/core/quantization/keras/quantize.py#L417
according to my analysis.
In conclusion, I would expect requires_output_quantize to be buggy otherwise there is an explanation for that.
I really appreciate if someone takes the time to explain this. Maybe I am wrong.
I look forward to your feedback.
Thanks,
Idriss
- Lingua principale
- Python
- Stelle
- 1.6k
- Fork
- 349
- Merge medio
- 3g 2h
- PR unite (30g)
- 1
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di tensorflow/model-optimization
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
tensorflow/model-optimization#1301 · 1 commento ·
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
tensorflow/model-optimization#1272 ·
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 50/100
tensorflow/model-optimization#1270 · 2 commenti ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
tensorflow/model-optimization#1241 ·
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
tensorflow/model-optimization#1182 · 1 commento ·
Tutte le issue di tensorflow/model-optimization
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
-
hcocena Apertapolicies-accepted pre-review precheck-passed
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
Bioconductor/BiocContributions#214 · 5 commenti ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
TencentCloud/Octop#1169 · 1 commento ·
-
[开源推荐] 在老板拷问你之前,先让 AI 灵魂拷问你 Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
521xueweihan/HelloGitHub#3778 ·
-
The version checker's trailing attribute region has no control for a less-than inside a quoted value Apertaarea: dashboard area: tests bug perceived difficulty: 2 python
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Nitjsefnie-Harness-Commons/daedalus#1105 · 1 commento ·