MCPcopy Create free account
hub / github.com/tensorpack/tensorpack / quantize

Function quantize

examples/DoReFa-Net/dorefa.py:12–19  ·  view source on GitHub ↗
(x, k)

Source from the content-addressed store, hash-verified

10 Return the three quantization functions fw, fa, fg, for weights, activations and gradients respectively
11 """
12 def quantize(x, k):
13 n = float(2 ** k - 1)
14
15 @tf.custom_gradient
16 def _quantize(x):
17 return tf.round(x * n) / n, lambda dy: dy
18
19 return _quantize(x)
20
21 def fw(x):
22 if bitW == 32:

Callers 3

fwFunction · 0.85
faFunction · 0.85
grad_fgFunction · 0.85

Calls 1

_quantizeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…