查看tensorflow Pb模型所有层的名字


代码如下:
import tensorflow as tf


def get_all_layernames():
    """get all layers name"""
    
    pb_file_path = '/home/nvidia/sq/facenet-master/model_checkpoints/free_grah.pb'

    from tensorflow.python.platform import gfile

    sess = tf.Session()
    # with gfile.FastGFile(pb_file_path + 'model.pb', 'rb') as f:
    with gfile.FastGFile(pb_file_path, 'rb') as f:
        graph_def = tf.GraphDef()
        graph_def.ParseFromString(f.read())
        sess.graph.as_default()
        tf.import_graph_def(graph_def, name='')

        tensor_name_list = [tensor.name for tensor in tf.get_default_graph().as_graph_def().node]
        for tensor_name in tensor_name_list:
            print(tensor_name, '\n')
            
            
            
get_all_layernames()
View Code

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM