我试图让KeithIto的Tacotron模型在带有NCS的Intel OpenVINO上运行。模型优化器无法将冻结的模型转换为IR格式。
在英特尔论坛上提问后,我被告知2018 R5版本不支持GRU,我将其更改为LSTM单元。但是模型经过训练后仍然可以在张量流中很好地运行。我也将OpenVINO更新为2019 R1版本。但是优化器仍然抛出错误。该模型主要有两个输入节点:input [N,T_in]和input_lengths [N];其中N是批处理大小,T_in是输入时间序列中的步数,值是字符ID,默认形状为[1 ,?]和[1]。 问题出在[1 ,?],因为模型优化器不允许使用动态形状。我尝试了不同的值,它总是会引发一些错误。
我尝试了冻结图,其中输出节点为“ model / griffinlim / Squeeze”,这是最终的解码器输出,还尝试了{https://github.com/keithito/tacotron/issues/95#issuecomment-362854371)中提到的“ model / inference / dense / BiasAdd”,它是Griffin-lim声码器,这样我就可以在模型外进行Spectrogram2Wav部分,并降低其复杂性。
C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\model_optimizer>python mo_tf.py --input_model "D:\Programming\LSTM\logs-tacotron\freezeinf.pb" --freeze_placeholder_with_value "input_lengths->[1]" --input inputs --input_shape [1,128] --output model/inference/dense/BiasAdd
Model Optimizer arguments:
Common parameters:
- Path to the Input Model: D:\Programming\Thesis\LSTM\logs-tacotron\freezeinf.pb
- Path for generated IR: C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\model_optimizer\.
- IR output name: freezeinf
- Log level: ERROR
- Batch: Not specified, inherited from the model
- Input layers: inputs
- Output layers: model/inference/dense/BiasAdd
- Input shapes: [1,128]
- Mean values: Not specified
- Scale values: Not specified
- Scale factor: Not specified
- Precision of IR: FP32
- Enable fusing: True
- Enable grouped convolutions fusing: True
- Move mean values to preprocess section: False
- Reverse input channels: False
TensorFlow specific parameters:
- Input model in text protobuf format: False
- Path to model dump for TensorBoard: None
- List of shared libraries with TensorFlow custom layers implementation: None
- Update the configuration file with input/output node names: None
- Use configuration file used to generate the model with Object Detection API: None
- Operations to offload: None
- Patterns to offload: None
- Use the config file: None
Model Optimizer version: 2019.1.0-341-gc9b66a2
[ ERROR ] Shape [ 1 -1 128] is not fully defined for output 0 of "model/inference/post_cbhg/conv_bank/conv1d_8/batch_normalization/batchnorm/mul_1". Use --input_shape with positive integers to override model input shapes.
[ ERROR ] Cannot infer shapes or values for node "model/inference/post_cbhg/conv_bank/conv1d_8/batch_normalization/batchnorm/mul_1".
[ ERROR ] Not all output shapes were inferred or fully defined for node "model/inference/post_cbhg/conv_bank/conv1d_8/batch_normalization/batchnorm/mul_1".
For more information please refer to Model Optimizer FAQ (<INSTALL_DIR>/deployment_tools/documentation/docs/MO_FAQ.html), question #40.
[ ERROR ]
[ ERROR ] It can happen due to bug in custom shape infer function <function tf_eltwise_ext.<locals>.<lambda> at 0x000001F00598FE18>.
[ ERROR ] Or because the node inputs have incorrect values/shapes.
[ ERROR ] Or because input shapes are incorrect (embedded to the model or passed via --input_shape).
[ ERROR ] Run Model Optimizer with --log_level=DEBUG for more information.
[ ERROR ] Exception occurred during running replacer "REPLACEMENT_ID" (<class 'extensions.middle.PartialInfer.PartialInfer'>): Stopped shape/value propagation at "model/inference/post_cbhg/conv_bank/conv1d_8/batch_normalization/batchnorm/mul_1" node.
For more information please refer to Model Optimizer FAQ (<INSTALL_DIR>/deployment_tools/documentation/docs/MO_FAQ.html), question #38.
我也尝试了不同的方法来冻结图形。
方法1: 转储图形后,使用Tensorflow中提供的freeze_graph.py:
tf.train.write_graph(self.session.graph.as_graph_def(), "models/", "graph.pb", as_text=True)
其次:
python freeze_graph.py --input_graph .\models\graph.pb --output_node_names "model/griffinlim/Squeeze" --output_graph .\logs-tacotron\freezeinf.pb --input_checkpoint .\logs-tacotron\model.ckpt-33000 --input_binary=true
方法2: 加载模型后使用以下代码:
frozen = tf.graph_util.convert_variables_to_constants(self.session,self.session.graph_def, ["model/inference/dense/BiasAdd"]) #model/griffinlim/Squeeze
graph_io.write_graph(frozen, "models/", "freezeinf.pb", as_text=False)
我希望冻结后可以删除BatchNormalization和Dropout层,但查看错误似乎仍然存在。
环境
操作系统:Windows 10 Pro
Python 3.6.5
Tensorflow 1.12.0
OpenVINO 2019 R1版本
有人可以通过优化程序解决上述问题吗?
答案 0 :(得分:0)
OpenVINO尚不支持此模型。我们会及时向您更新。