sdk版本6.4.4.3,依照文档里混合量化的步骤走的
1、常规量化得到quantize文件
../bin/tensorzonex --action quantization --dtype float32 --quantized-dtype asymmetric_affine-u8 --channel-mean-value '0 0 0 255' --source text --source-file data.txt --model-input my_superpoint.json --model-data my_superpoint.data --quantized-rebuild --batch-size 1 --epochs 349 --reorder-channel '2 1 0'
2、修改quantize文件
customized_quantize_layers: {Conv_des_2:dynamic_fixed_point-16}
在json里的层名:
3、混合量化
../bin/tensorzonex --action quantization --dtype float32 --quantized-dtype asymmetric_affine-u8 --channel-mean-value '0 0 0 255' --source text --source-file data.txt --model-input my_superpoint.json --model-data my_superpoint.data --quantized-hybrid --batch-size 1 --epochs 349 --reorder-channel '2 1 0' --model-quantize my_superpoint.quantize
报错:
I Namespace(action='quantization', batch_size=1, caffe_mean_file=None, capture_format='nchw', capture_quantized=False, channel_mean_value='0 0 0 255', config=None, data_output=None, debug=False, device=None, divergence_first_quantize_bits=11, dtype='float32', epochs=349, epochs_per_decay=100, force_gray=False, fpfs_delta0=1, fpfs_epochs=0, fpfs_reduce_target=0, input_fitting='scale', input_normalization=None, lr=0.1, mean_file=None, model_data='my_superpoint.data', model_data_format='zone', model_input='my_superpoint.json', model_quantize='my_superpoint.quantize', optimizer='momentum', output_dir=None, output_num=5, pb_name=None, pfps_delta0=1, pfps_epochs=0, pfps_reduce_target=0, prune_epochs=10, prune_loss=1, quantized_algorithm='normal', quantized_divergence_nbins=0, quantized_dtype='asymmetric_affine-u8', quantized_hybrid=True, quantized_moving_alpha=0.0, quantized_rebuild=False, quantized_rebuild_all=False, random_brightness=None, random_contrast=None, random_crop=False, random_flip=False, random_mirror=False, reorder_channel='2 1 0', restart=False, samples=-1, source='text', source_file='data.txt', task='classification', validation_output='validation.csv', without_update_masked_grad=False)
2021-06-30 15:13:22.370606: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2021-06-30 15:13:22.390021: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3699850000 Hz
2021-06-30 15:13:22.390587: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x453d260 executing computations on platform Host. Devices:
2021-06-30 15:13:22.390601: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): Host, Default Version
I Load model in my_superpoint.json
I Load data in my_superpoint.data
I Const @Conv_des_2:weight created
I Tensor @Conv_des_2:weight type: float32
I Const @Conv_des_2:bias created
I Tensor @Conv_des_2:bias type: float32
I Const @Conv_scor_3:weight created
I Tensor @Conv_scor_3:weight type: float32
I Const @Conv_scor_3:bias created
I Tensor @Conv_scor_3:bias type: float32
I Const @Conv_47_6:weight created
I Tensor @Conv_47_6:weight type: float32
I Const @Conv_47_6:bias created
I Tensor @Conv_47_6:bias type: float32
I Const @Conv_44_7:weight created
I Tensor @Conv_44_7:weight type: float32
I Const @Conv_44_7:bias created
I Tensor @Conv_44_7:bias type: float32
I Const @Conv_42_9:weight created
I Tensor @Conv_42_9:weight type: float32
I Const @Conv_42_9:bias created
I Tensor @Conv_42_9:bias type: float32
I Const @Conv_40_11:weight created
I Tensor @Conv_40_11:weight type: float32
I Const @Conv_40_11:bias created
I Tensor @Conv_40_11:bias type: float32
I Const @Conv_37_14:weight created
I Tensor @Conv_37_14:weight type: float32
I Const @Conv_37_14:bias created
I Tensor @Conv_37_14:bias type: float32
I Const @Conv_35_16:weight created
I Tensor @Conv_35_16:weight type: float32
I Const @Conv_35_16:bias created
I Tensor @Conv_35_16:bias type: float32
I Const @Conv_32_19:weight created
I Tensor @Conv_32_19:weight type: float32
I Const @Conv_32_19:bias created
I Tensor @Conv_32_19:bias type: float32
I Const @Conv_30_21:weight created
I Tensor @Conv_30_21:weight type: float32
I Const @Conv_30_21:bias created
I Tensor @Conv_30_21:bias type: float32
I Const @Conv_27_24:weight created
I Tensor @Conv_27_24:weight type: float32
I Const @Conv_27_24:bias created
I Tensor @Conv_27_24:bias type: float32
I Const @Conv_25_26:weight created
I Tensor @Conv_25_26:weight type: float32
I Const @Conv_25_26:bias created
I Tensor @Conv_25_26:bias type: float32
W:tensorflow:From acuitylib/app/tensorzone/workspace.py:26: py_func (from tensorflow.python.ops.script_ops) is deprecated and will be removed in a future version.
Instructions for updating:
tf.py_func is deprecated in TF V2. Instead, there are two
options available in V2.
- tf.py_function takes a python function which manipulates tf eager
tensors instead of numpy arrays. It's easy to convert a tf eager tensor to
an ndarray (just call tensor.numpy()) but having access to eager tensors
means `tf.py_function`s can use accelerators such as GPUs as well as
being differentiable using a gradient tape.
- tf.numpy_function maintains the semantics of the deprecated tf.py_func
(it is not differentiable, and manipulates numpy arrays). It drops the
stateful argument making all functions stateful.
I Fitting image with scale.
I Reorder channels.
I Channel mean value [0.0, 0.0, 0.0, 255.0]
I [TRAINER]Quantization start...
[TRAINER]Quantization start...
I Init validate tensor provider.
I Enqueue samples 349
I Init provider with 349 samples.
I Load quantization tensor table my_superpoint.quantize
D Optimizing network with qnt_insert_converter_layer
Traceback (most recent call last):
File "tensorzonex.py", line 450, in <module>
File "tensorzonex.py", line 387, in main
File "acuitylib/app/tensorzone/quantization.py", line 174, in run
File "acuitylib/app/tensorzone/quantization.py", line 113, in _run_quantization
File "acuitylib/app/tensorzone/quantization.py", line 96, in _quantize_net
File "acuitylib/app/tensorzone/quantization.py", line 77, in _generate_hybrid_table
File "acuitylib/optimize/optimizer.py", line 238, in apply
File "acuitylib/optimize/rules/quantize/hybrid_insert_converter_layer.py", line 217, in apply
AttributeError: 'NoneType' object has no attribute 'is_op'
[339549] Failed to execute script tensorzonex
我试过在quantize文件里customized_quantize_layers换成其他层,也是报错,换成float32也是报错,customized_quantize_layers不填任何东西就能跑,但我需要混合量化,不知道是哪儿出了问题?