LoginSignup
0
0

More than 1 year has passed since last update.

ONNXモデルに出力ノードを追加する方法

Posted at

ONNXモデルの途中層から出力を得たかったので調べた結果をメモります。

import onnx

# モデルの出力ファイル名
model_path = "path to model"

model = onnx.load(model_path)

input_path = 'path to load model'
output_path = 'path to save model'
input_names = ['input_1']
output_names = ['Logits_softmax', 'Logits_softmax_Flatten'] # 左が元々あったノード 、 右が追加するノード

onnx.utils.extract_model(input_path, output_path, input_names, output_names)

スクリーンショット 2021-10-05 3.22.55.png

ピンクの丸が追加した出力ノードになります。
これでSoftmaxの手前の出力が取得できるようになりました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0