Tensorflow 是否可以将tf.contrib.quantize.create_training_图与Keras模型一起使用?

Tensorflow 是否可以将tf.contrib.quantize.create_training_图与Keras模型一起使用?,tensorflow,keras,deep-learning,quantization,tensorflow-lite,Tensorflow,Keras,Deep Learning,Quantization,Tensorflow Lite,是否可以使用tf.contrib.quantize.create_training_graph对已训练的Keras模型进行模型量化 据我所知,我可以从Keras模型中导入tf.Graph,但我可以在使用tf.contrib.quantize.create_training_Graph修改后对其进行微调吗 在模型定义和模型加载之后,我可以调用tf.contrib.quantize.create\u training\u graph(输入图=K.get\u session().graph,quant

是否可以使用
tf.contrib.quantize.create_training_graph
对已训练的Keras模型进行模型量化

据我所知,我可以从Keras模型中导入
tf.Graph
,但我可以在使用
tf.contrib.quantize.create_training_Graph
修改后对其进行微调吗

在模型定义和模型加载之后,我可以调用
tf.contrib.quantize.create\u training\u graph(输入图=K.get\u session().graph,quant\u delay=int(0))
,但是得到:

2019-02-22 14:56:24.216742: W tensorflow/c/c_api.cc:686] Operation '{name:'global_average_pooling2d_1_1/Mean' id:3777 op device:{} def:{global_average_pooling2d_1_1/Mean = Mean[T=DT_FLOAT, Tidx=DT_INT32, keep_dims=false](conv2d_15_1/act_quant/FakeQuantWithMinMaxVars:0, global_average_pooling2d_1_1/Mean/reduction_indices)}}' was changed by updating input tensor after it was run by a session. This mutation will have no effect, and will trigger an error in the future. Either don't modify nodes after running them or create a new session.
至少在转换到keras->tensorflow->tflite时,我能够用uint8权重保存模型,因为我知道模型的输入和推断仍然是fp32

converter = tf.contrib.lite.TFLiteConverter.from_frozen_graph(
        graph_def_file='tf_model.pb',
        input_arrays=input_node_names,
        output_arrays=output_node_names)

converter.post_training_quantize = True

tflite_model = converter.convert()

在中,您可以找到解决问题的方法