@@ -13,14 +13,19 @@ Refer to `Tensorflow quantization-aware training <https://github.com/tensorflow/
After pre-training model using float point, estimate output range of each activation layer using sample inputs.
.. note::
`quantize_weights` and `quantize_nodes` should not be specified when using `TransformGraph` tool if using MACE quantization.
Quantization-aware training
----------------------------
It is recommended that developers fine tune the fixed-point model, as experiments show that by this way accuracy could be improved, especially for lightweight
models, e.g., MobileNet. The only thing you need to make it run using MACE is to add the following config to model yaml file:
1. `input_ranges`: the ranges of model's inputs, e.g., -1.0,1.0.
1. `input_ranges`: the ranges of model's inputs, e.g., -1.0,1.0.
2. `quantize`: set `quantize` to be 1.
2. `quantize`: set `quantize` to be 1.
Post training quantization
...
...
@@ -29,46 +34,81 @@ MACE supports post-training quantization if you want to take a chance to quantiz
This method requires developer to calculate tensor range of each activation layer statistically using sample inputs.
MACE provides tools to do statistics with following steps:
1. Convert original model to run on CPU host without obfuscation (by setting `target_abis` to `host`, `runtime` to `cpu`,
and `obfuscate` to `0`, appending `:0` to `output_tensors` if missing in yaml config).
1. Convert original model to run on CPU host without obfuscation (by setting `target_abis` to `host`, `runtime` to `cpu`,
and `obfuscate` to `0`, appending `:0` to `output_tensors` if missing in yaml config).
2. Log tensor range of each activation layer by inferring several samples on CPU host. Sample inputs should be
representative to calculate the ranges of each layer properly.
2. Log tensor range of each activation layer by inferring several samples on CPU host. Sample inputs should be
representative to calculate the ranges of each layer properly.
.. code-block:: sh
.. code-block:: sh
# Convert images to input tensors for MACE, see image_to_tensor.py for more arguments.