# Quantisation Aware Training

**URL:** <https://discuss.ai.google.dev/t/quantisation-aware-training/25716>\
**Category:** General Discussion\
**Tags:** models, help\_request\
**Created:** [July 21, 2021, 1:49pm UTC](https://discuss.ai.google.dev/t/quantisation-aware-training/25716 "2021-07-21T13:49:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sayan\_Nath](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/sayan_nath/32/6947_2.png) [@Sayan\_Nath](https://discuss.ai.google.dev/u/Sayan_Nath)\
**Post date:** [July 21, 2021, 1:49pm UTC](https://discuss.ai.google.dev/t/quantisation-aware-training/25716/1 "2021-07-21T13:49:01Z")

</div>

Hi!

I have trained my model using MobileNetV3 architecture

```auto
def get_training_model(trainable=False):
    # Load the MobileNetV3Small model but exclude the classification layers
    EXTRACTOR = MobileNetV3Small(weights="imagenet", include_top=False,
                    input_shape=(IMG_SIZE, IMG_SIZE, 3))
    # We will set it to both True and False
    EXTRACTOR.trainable = trainable
    # Construct the head of the model that will be placed on top of the
    # the base model
    class_head = EXTRACTOR.output
    class_head = GlobalAveragePooling2D()(class_head)
    class_head = Dense(1024, activation="relu")(class_head)
    class_head = Dense(512, activation="relu")(class_head)
    class_head = Dropout(0.5)(class_head)
    class_head = Dense(NUM_CLASSES, activation="softmax", dtype="float32")(class_head)

    # Create the new model
    classifier = tf.keras.Model(inputs=EXTRACTOR.input, outputs=class_head)

    # Compile and return the model
    classifier.compile(loss="sparse_categorical_crossentropy", 
                          optimizer="adam",
                          metrics=["accuracy"])

    return classifier

```

But when I am doing Quantisation Aware Training it is giving me an error.

 ![image](https://d3qe71uytubmmx.cloudfront.net/original/2X/0/028e28afb05390283dd0e9fa824e14f5468b7a38.png)

---

<div class="post-metadata">

**Author:** ![ymodak](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/ymodak/32/52565_2.png) [@ymodak](https://discuss.ai.google.dev/u/ymodak)\
**Post date:** [July 21, 2021, 7:00pm UTC](https://discuss.ai.google.dev/t/quantisation-aware-training/25716/3 "2021-07-21T19:00:10Z")

</div>

Can you try without setting `dtype` to float as `string`? By default the `dtype` is set to `float32`

> [@Sayan\_Nath](#):
>
> `class_head = Dense(NUM_CLASSES, activation="softmax")(class_head)`

Also if you can provide a reproducible code example that will be great.

---

<div class="post-metadata">

**Author:** ![Sayan\_Nath](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/sayan_nath/32/6947_2.png) [@Sayan\_Nath](https://discuss.ai.google.dev/u/Sayan_Nath)\
**Post date:** [July 21, 2021, 7:17pm UTC](https://discuss.ai.google.dev/t/quantisation-aware-training/25716/4 "2021-07-21T19:17:40Z")

</div>

Yes, I tried with that first. It was having the same problem
