TFOpLambda not supported in INT8 Quantization Aware Training (Mobilenetv3)
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- python, tensorflow
调研方向
首先,使用 tf_keras MobileNetV3Small 和 tfmot.quantization.keras.quantize_model 运行所提供的 Python 复现代码。跟踪由 hard-swish 激活创建的 TFOpLambda 如何进入量化流程,以及 list-versus-dtype 错误发生的位置。完成的标准是模型能够在不出现此错误的情况下成功量化,同时保留所报告的复现案例。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
I cannot quantize Mobilenetv3 from keras2 because the hard-swish activation fuction is implemented as a TFOpLambda.
System information
tensorflow version: 2.17
tf_keras version: 2.17
tensorflow_model_optimization version: 0.8.0
TensorFlow Model Optimization version installed from pip
Python version: Python 3.9.19
Describe the expected behavior
Quantization aware training can be applied to keras.applications.MobileNetV3Small using tfmot.quantization.keras.quantize_model
Describe the current behavior
When some layer is a TFOpLambda the following error raises:
AttributeError: Exception encountered when calling layer "tf.operators.add" (type TFOpLambda).
'list' object has no attribute 'dtype'
Call arguments received by layer "tf.operators.add" (type TFOpLambda):
• x=['tf.Tensor(shape=(None, 112, 112, 16), dtype=float32)']
• y=3.0
• name=None
Code to reproduce the issue
import os
os.environ["TF_USE_LEGACY_KERAS"] = "1"
import tf_keras as keras
model = keras.applications.MobileNetV3Small(
input_shape=tuple([224,224,3]),
alpha=1.0,
minimalistic=False,
include_top=True,
weights="imagenet",
input_tensor=None,
classes=1000,
pooling=None,
dropout_rate=0.2,
classifier_activation="softmax",
include_preprocessing=True,
)
import tensorflow_model_optimization as tfmot
quantize_model = tfmot.quantization.keras.quantize_model
# q_aware stands for for quantization aware.
q_aware_model = quantize_model(model)
- 主要语言
- Python
- 星标
- 1.6k
- 派生
- 349
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
tensorflow/model-optimization 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
tensorflow/model-optimization#1301 · 1 条评论 ·
-
bug
难度 4/5 3-5 天 新手友好度 48/100
tensorflow/model-optimization#1272 ·
-
bug
难度 3/5 1-2 天 新手友好度 50/100
tensorflow/model-optimization#1270 · 2 条评论 ·
-
bug
难度 2/5 1-3 小时 新手友好度 48/100
tensorflow/model-optimization#1241 ·
-
bug
难度 4/5 3-5 天 新手友好度 35/100
tensorflow/model-optimization#1182 · 1 条评论 ·
查看 tensorflow/model-optimization 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
PedestrianDynamics/pyFDS-Evac#343 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
theskumar/python-dotenv#708 ·
-
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 2 天内回复
-
Docs Timedelta
难度 2/5 1-3 小时 新手友好度 72/100
pandas-dev/pandas#69919 ·
维护者通常 1 天内回复
-
API documentation
难度 2/5 1-3 小时 新手友好度 72/100
zephyrproject-rtos/west#1009 · 2 条评论 ·
维护者通常 3 天内回复