Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

QAT aware training for mobilenetV2 not working

Aperta
#1,086 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

@Xhark ci sta già lavorando.

Dal 28/8/2023.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

Hello I am trying to apply quantization aware training for mobilenet, and I am testing on the mnist dataset, the floating point models works very well but the moment I add the quantization I have a very huge loss and the model isn't converging.

definition of the model :

`
def build_model(target_size):
input_tensor = Input(shape=(target_size, target_size, 3))
base_model = applications.MobileNetV2(
include_top=False,
weights='imagenet',
input_tensor=input_tensor,
input_shape=(target_size, target_size, 3),
pooling='avg')

for layer in base_model.layers:
    layer.trainable = False  # trainable has to be false in order to freeze the layers

op = Dense(256, activation='relu')(base_model.output)
op = Dropout(.25)(op)

output_tensor = Dense(10, activation='softmax')(op)

model = Model(inputs=input_tensor, outputs=output_tensor)

return model`

quantization and training:

def quantized_model(model_fp32): quantize_model = tfmot.quantization.keras.quantize_model q_aware_model = quantize_model(model_fp32) return q_aware_model

`q_aware_model = quantized_model(model_fp32)
q_aware_model.compile(optimizer='adam',
loss='categorical_crossentropy',
metrics=['categorical_accuracy'])

print("training model with int8 precision")

train_images_subset = train_images[0:1000] # out of 60000
train_labels_subset = train_labels[0:1000]
encoded_y_quant_train = to_categorical(train_labels_subset, num_classes=10, dtype='float32')

train_quant_generator = load_data_generator(train_images_subset, encoded_y_quant_train, batch_size=64)

q_aware_model.fit(train_quant_generator,
                batch_size=500, epochs=1, steps_per_epoch=900)`
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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di tensorflow/model-optimization

Tutte le issue di tensorflow/model-optimization

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.