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.
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`
Would you please add some more details that how did you evaluate and what's the expected output?
Can you try full dataset (0:60000) instead of 0:1000 for QAT? Thanks!
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')
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'])