[英]QAT output nodes for Quantized Model got the same min max range
Recently, I have worked on quantization aware training on tf1.x to push the model to Coral Dev Board.最近,我在 tf1.x 上进行了量化感知训练,以将模型推送到 Coral Dev Board。 However, when I finished training the model, why is my min max of my 2 outputs fake quantization is the same?但是,当我完成模型训练后,为什么我的 2 个输出伪量化的最小值最大值相同?
Should it be different when one's maximum target is 95 and one is 2pi?当一个人的最大目标是 95 和一个是 2pi 时,它应该不同吗?
I have figured out the problem.我已经想通了这个问题。 It is the problem when that part of the model is not really trained QAT.当模型的那部分没有真正训练过 QAT 时,就会出现问题。 This happens for the output node that somehow forgets to QAT when training.这种情况发生在训练时不知何故忘记 QAT 的输出节点。 The -6 and 6 values come from the default source of the quantization of tf1.x as mention here -6 和 6 值来自这里提到的 tf1.x 量化的默认来源
To overcome the problem, we should provide some op to trigger the QAT for the output nodes.为了克服这个问题,我们应该提供一些操作来触发输出节点的 QAT。 In my regression case, I add a dummy op: tf.maximum(output,0) in the model to make the node QAT.在我的回归案例中,我在模型中添加了一个虚拟操作:tf.maximum(output,0) 以使节点 QAT。 If your output is strictly between 0-1, applying "sigmoid" activation at output instead of relu can also solve the problems.如果您的输出严格在 0-1 之间,则在输出处应用“sigmoid”激活而不是 relu 也可以解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.