tensorflow / tensorflow/model-optimization

Issue for the FAKE_QUANT result

Open
#858 4 comments 0 reactions 1 assignee View on GitHub

@Xhark is already working on this.

Since Oct 12, 2021.

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

Description

Hi,
For the example:
a=tf.fake_quant_with_min_max_vars([-1.0,0.0,1.0], min=-1, max=1)
sess=tf.Session()
sess(a)
The result is array([-0.9960785, 0. , 1.0039215], dtype=float32)

But according to the source code "fake_quant_ops_functor.h":
it define the:
*scale = (max - min) / (quant_max_float - quant_min_float);
zero_point_from_min = quant_min_float - min / *scale;
nudged_zero_point = StdRound(zero_point_from_min);
*nudged_min = (quant_min_float - nudged_zero_point) * (*scale);
*nudged_max = (quant_max_float - nudged_zero_point) * (*scale);

So, i think the result should be [-1.0039215, 0. , 0.9960785].
Please help me to resolve the confusion.
Thanks

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.