Custom layer with Concat afterwards causes an error during QAT modeling
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- keras, python
- Ambito
- machine-learning
Direzione di ricerca
Non viene indicato alcun file o test del repository. Inizia con il riproduttore fornito di build_model e apply_quantization_to_dense, quindi esegui quantize_apply sul modello annotato per isolare il problema relativo a CustomLayer, Concatenate e Dense; il lavoro è completato quando il modello fornito genera un modello QAT senza il TypeError.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Prior to filing: check that this should be a bug instead of a feature request. Everything supported, including the compatible versions of TensorFlow, is listed in the overview page of each technique. For example, the overview page of quantization-aware training is here. An issue for anything not supported should be a feature request.
Describe the bug
I am building a model that returns feature embedding as an output.
I used MobileNetV3Largs as a baseline with include_top=False option.
after the baseline, I have few layers and concat them at the end of the model.
When I tried to apply QAT on the model though, it returns the error saying:
TypeError: 'str' object is not callable
System information
TensorFlow version (installed from source or binary):
2.15.0
TensorFlow Model Optimization version (installed from source or binary):
0.7.5
Python version:
3.11.7
Describe the expected behavior
QAT model generated well.
Describe the current behavior
TypeError: 'str' object is not callable
Code to reproduce the issue
Provide a reproducible code that is the bare minimum necessary to generate the
problem.
def build_model(args, include_preprocessing=False):
IMG_SHAPE = (args.input_dim, args.input_dim, 3)
# Transfer learning model with MobileNetV3
base_model = tf.keras.applications.MobileNetV3Large(
input_shape=IMG_SHAPE,
include_top=False,
weights='imagenet',
minimalistic=True,
include_preprocessing=include_preprocessing
)
# Freeze the pre-trained model weights
base_model.trainable = False
cl1 = CustomLayer()(base_model.output)
cl1 = tf.keras.layers.Dropout(0.2, name="dropout_cl1")(cl1)
cl2 = CustomLayer()(base_model.output)
cl2 = tf.keras.layers.Dropout(0.2, name="dropout_gd2")(gd2)
cl3 = CustomLayer()(base_model.output)
cl3 = tf.keras.layers.Dropout(0.2, name="dropout_cl1")(cl3)
concat_cls = tf.keras.layers.Concatenate()([cl1, cl2, cl3])
x = tf.keras.layers.Dense(512, activation='swish')(concat_cls) # No activation on final dense layer
model = tf.keras.Model(base_model.input, x)
return model
# This is initial training loop before QAT --> this returns few epoch trained model
model = build_model(args)
model = initial_training(args, model)
def apply_quantization_to_dense(layer):
if isinstance(layer, tf.keras.layers.Dense):
return tfmot.quantization.keras.quantize_annotate_layer(layer)
return layer
annotated_model = tf.keras.models.clone_model(
model,
clone_function=apply_quantization_to_dense,
)
quant_aware_model = tfmot.quantization.keras.quantize_apply(annotated_model)
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
- Lingua principale
- Python
- Stelle
- 1.6k
- Fork
- 349
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi 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à 2/5 1-3 ore Idoneità per principianti 88/100
BasedHardware/omi#20271 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
openai/openai-cookbook#3153 ·
I maintainer di solito rispondono entro 1 giorno
-
cvss-severity:high devguard l3montree-cybersecurity/devguard/devguard pkg:golang/github.com/l3montree-dev/devguard risk:low state:open
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
l3montree-dev/devguard#3146 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
bug confirmed issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
open-webui/open-webui#31849 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno