Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

trainable=False doesn't work for QuantizeWrapperV2

未关闭
#1,067 1 条评论 1 个 reaction 已指派 1 人 在 GitHub 查看

@cdh4696 已经在做这个了。

开始于 2023年5月3日。

评估

这个 Issue 还没有评估数据。

描述

bug

Prior to filing: check that this should be a bug instead of a feature request. Everything supported, including the compatible versions of TensorFlow, is listed in the overview page of each technique. For example, the overview page of quantization-aware training is here. An issue for anything not supported should be a feature request.

Describe the bug
Setting layer.trainable=False for a QuantizeWrapperV2 wrapped Dense layer doesn't convert all trainable weights to non-trainable.

System information

TensorFlow version (installed from source or binary):
2.12.0

TensorFlow Model Optimization version (installed from source or binary):
0.7.4

Python version:
3.10.11

Describe the expected behavior
Like the normal model, by setting layer.trainable=False for the quantized layer, the layer's weights should all become non-trainable.

Describe the current behavior
After setting layer.trainable=False for a quantized Dense layer, the Dense layer still contains trainable weights.

Code to reproduce the issue
The colab contains the code to reproduce this bug.
https://colab.research.google.com/drive/1KYnZkBI_g3Pu9Vqz4UneXCtNOs3_kB39?usp=sharing

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
The output from the colab is below. Noted that by setting layer.trainable=False, the original model's Dense layer's weights become non-trainable. However, the dense_11/kernel:0 from the Dense layer in the quantized model is still trainable after setting layer.trainable=False.

trainable variables in model:  2
trainable variables in model after setting trainable to false:  0
trainable variables in quantized model:  1
trainable variables in quantized model after setting trainable to false:  1
dense_11/kernel:0
主要语言
Python
星标
1.6k
派生
349
平均合并
3 天 2 小时
30 天内合并 PR
1

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

tensorflow/model-optimization 的其他 Issue

查看 tensorflow/model-optimization 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。