保存されたモデルoutput_graph.pb
からすべての重み/バイアスを抽出しようとしています。tf.GraphKeys.TRAINABLE_VARIABLES on output_graph.pb空リストの結果
私がモデル読み:
def create_graph(modelFullPath):
"""Creates a graph from saved GraphDef file and returns a saver."""
# Creates graph from saved graph_def.pb.
with tf.gfile.FastGFile(modelFullPath, 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
tf.import_graph_def(graph_def, name='')
GRAPH_DIR = r'C:\tmp\output_graph.pb'
create_graph(GRAPH_DIR)
をそして、私は、各レイヤ内のすべての重み/バイアスを 抽出することができるだろう期待してこれを実行しようとしました。
with tf.Session() as sess:
all_vars = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES)
print (len(all_vars))
しかし、私はlenとして0の値を得ています。
最後の目標は、重みと偏りを抽出し、テキストファイル/ np.arraysに保存することです。