KeithIto の Tacotron モデルを、NCS を使用して Intel OpenVINO で実行しようとしています。モデル オプティマイザーは、凍結されたモデルを IR 形式に変換できません。
Intel フォーラムで質問したところ、2018 R5 リリースには GRU サポートがないと言われ、LSTM セルに変更しました。しかし、モデルはトレーニング後も tensorflow でうまく動作します。また、OpenVINO を 2019 R1 リリースに更新しました。しかし、オプティマイザは依然としてエラーをスローしました。このモデルには主に、inputs[N,T_in] と input_lengths[N] の 2 つの入力ノードがあります。ここで、N はバッチ サイズ、T_in は入力時系列のステップ数、値はデフォルトの形状が [1,?] および [1] の文字 ID です。問題は [1,?] にあります。これは、モデル オプティマイザーが動的形状を許可しないためです。さまざまな値を試しましたが、常にいくつかのエラーがスローされます。
最終的なデコーダー出力である出力ノード「model/griffinlim/Squeeze」と、「model/inference/dense/BiasAdd」でグラフを凍結してみました ( https://github.com/keihito/tacotron/issues/ 95#issuecomment-362854371 ) これは 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 レイヤーが削除されることを期待していましたが、エラーを見るとまだ存在しているようです。
環境
OS: Windows 10 プロ
パイソン 3.6.5
テンソルフロー 1.12.0
OpenVINO 2019 R1 リリース
オプティマイザーに関する上記の問題を解決できる人はいますか?