计算图结构
- MetaGraphDef(计算图)
- MetaInfoDef(运算方法)
- OpList(运算方法集合)
- OpDef(运算方法)
- ArgDef(输入,输出)
- AttrDef(属性)
- OpDef(运算方法)
- OpList(运算方法集合)
- GraphDef (连接结构)
- NodeDef(节点)
- SaverDef (模型持久化)
- CheckpointFormatVersion(模型定义使用的版本)
- map<string, CollectionDef> (集合)
- NodeList(节点value)
- BytesList(序列化value)
- map<string, SignatureDef>(签名)
- AssetFileDef (权重值)
- MetaInfoDef(运算方法)
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
}
}