基於OpenVINO的多輸入model optimizer(Tensorflow)


Step I:下載預訓練模型

wget -O - https://github.com/mozilla/DeepSpeech/releases/download/v0.3.0/deepspeech-0.3.0-models.tar.gz | tar xvfz -

文件內容如下

 

StepII:利用tensorflow中的summarize_graph對fronzen后的網絡結構進行可視化

首先執行如下語句:得到大致的輸入輸出信息

bazel-bin/tensorflow/tools/graph_transforms/summarize_graph --in_graph="/home/gsj/mutil_input/models/output_graph.pb" --print_structure=false

輸出信息如下:

 

存在四個輸入:分別為input_node,input_lengths,previous_state_c,previous_state_h,輸入形狀分別為:[1,16,19,26] [1] [1,2048] [1,2048]

輸出節點為:logits

將上述命令中的—print_structure設置為true得到精確的網絡結構,部分結構如下圖所示

 

輸出節點由上可以得到raw_logits,^Assign_2,^Assign_3三個節點。往上查^Assign_2的節點,發現節點為previous_state_c,lstm_fused_cell/Gather ^Assign_3中為previous_state_h,lstm_fused_cell/Gather_1

查找previous_state_c及previous_state_h的相關節點的輸入節點分別為

previous_state_c/read , previous_state_h/read

for benchmark_model:

bazel run tensorflow/tools/benchmark:benchmark_model -- --graph=/home/gsj/mutil_input/models/output_graph.pb --show_flops --input_layer=input_node,input_lengths,previous_state_c,previous_state_h --input_layer_type=float,int32,float,float --input_layer_shape=1,16,19,26:1:1,2048:1,2048 --output_layer=logits

 

 

Step III: Model optimizer生成IR文件

python3.6 mo.py --input_model /home/gsj/mutil_input/models/output_graph.pb --input input_node,previous_state_h/read,previous_state_c/read,input_lengths     --input_shape [1,16,19,26],[1,2048],[1,2048],[1] --output raw_logits,lstm_fused_cell/Gather,lstm_fused_cell/Gather_1 --freeze_placeholder_with_value "input_lengths->[16]"

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM