tensorflow / tensorflow/model-optimization

Cannot use Quantize layer and use abstract class and methods

Open
#1,122 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
1.6k
Forks
349
Avg merge
3d 2h
Merged PRs (30d)
1

Description

I am trying to Quantize the whole model but whenever, I try to load the model using quantized scope it gives me error like this

import sys, os
import numpy as np
import tensorflow as tf
from tensorflow.keras.models import load_model
import tensorflow_model_optimization as tfmot
from tensorflow.keras.utils import CustomObjectScope

customObjects = {'DefaultQuantizeConfig': tfmot.quantization.keras.QuantizeConfig}       
with tfmot.quantization.keras.quantize_scope(customObjects):
    loaded_model = load_model('UpdtQuant.h5')
image

Also, when I try to define scope it gives me unknown value error: Quantize layer is not defined

Can someone help me with this issue?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Python reproducer in the issue and the error shown when loading UpdtQuant.h5 inside tfmot.quantization.keras.quantize_scope. Check how quantize_scope registers quantization objects and how the abstract QuantizeConfig value is serialized. Done means identifying the missing registration or confirming the supported way to load the quantized model.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.