tensorflow数据结构-GraphDef


计算图结构

  1. MetaGraphDef(计算图)

文章目录

GraphDef

只关注计算图的连接结构信息, 根据连接结构中”索引“在MetaInfoDef中寻找节点运算的具体

message GraphDef {
  repeated NodeDef node = 1;
  // 版本号
  VersionDef versions = 4;
  // 实验性的版本号
  int32 version = 3 [deprecated = true];
  FunctionDefLibrary library = 2;
};

NodeDef

message NodeDef {
	//节点的唯一标识符,可以通过节点名称来获取相应的节点
    string name = 1;
    
    //使用的运算方法的名称,通过这个名称可在tensorflow计算图元图的
    //MetaInfoDef属性中找到该运算的剧吐信息
    string op = 2;
    
    //一个字符串列表,定义运算的输入
    repeated string input = 3;
    
    //指定该节点运行的设备
    //通过device属性指定处理这个运算的设备,当device属性为空时,
    //Tensorflow将自动选择最合适的设备来运行这个运算
    string device = 4;
    
    // 名字到具体属性的映射
    map<string,AttrrValue> attr = 5;
}

案列

graph_def {

	// 变量Variable节点
    nodo {
        name : "v1"
        op : "Variable"
        attr {
            key : "_output_shapes"
            value {
                list{ shape { dim { size : 1}}}
            }
        }
        attr {
            key : "dtype"
            value {
                tpye : DT_FLOAT
            }
        }
        ····
    }
    
    // Add 节点
    // 指定了2给输入,v1/read 表示可以读取v1的值,如果v1有多个输出值
    // 则必须使用 v1/read:src_output 指定,src_output 表示节点的第
    // src_output输出(从0开始),如果获取的时第1给输出,则可以省略”:src_output"
    // 直接写成 v1/read
    node {
        name : "add"
        op : "Add"
        input : "v1/read"
        input : "v2/read"
        ···
    }
    
    // 该节点时系统在完成Tensorflow模型保存过程中自动生成的一个运算
    node {
        name : "save/control_dependency"
        op : "Identity"
        ···
    }
    
    // 版本号
    versions {
        producer : 9
    }
}

猜你喜欢

转载自blog.csdn.net/qq_39124762/article/details/83857252
今日推荐