结构梳理详见:Pytorch&先后端工做梳理html
如下介绍先后端对接的json文件前端
描述:包含全部基础的网络层,已经in和out节点json
{ "type": "base", //sequential表示嵌套模型,base表示单个网络层 "name": "base_1", //对于base层为网络层对应的名字,默认按序号排列 "attribute": { "layer_type": "pool_layer", //对于base attribute的结构,以pool_layer为例 //对于输入和输出层,"layer_type":"in"/"out",仅有"left"/"right"属性 "attribute": { "layer_type": "max_pool", "attribute": { "kernel_size": 2, "stride": 2, "padding": 0 } }, "left": "XXXpx", //绘制时的位置,Sequential可缺省该属性 "Right": "XXXpx" //绘制时的位置,Sequential可缺省该属性 } }
描述:在sequential中用以描述canvas链接的文件canvas
{ "source": { "id": "canvas_%d", "anchor_position": "Bottom" //("Bottom"/"Up"/"Left"/"Right"), //对于type=base表示箭头链接位置,对于Sequential可缺省 }, "target": { "id": "canvas_%d", "anchor_position": "Up" //("Bottom"/"Up"/"Left"/"Right"), //对于type=base表示箭头链接位置,对于Sequential可缺省 } }
描述:核心的封装结构,有明确且单一的输入和输出节点后端
{ "type": "sequential", //sequential表示嵌套模型,base表示单个网络层 "name": "sequential 01", //对于Sequential为用户在保存网络层时为网络层取的名字,默认按照sequential_%d来排序 "attribute": { "in": "canvas_%d", //表示每一个Sequential开始节点,即入度为0的节点,该节点必定是type="base" && attribute.layer_type = "in" "out": "canvas_%d", //表示每一个Sequential结束节点,即出度为0的节点,该节点必定是type="base" && attribute.layer_type = "out" //对于Sequential attribute的结构 "nets": { "canvas_%d": "sequential1.json", //这里能够是sequential.json或者base.json,modulelist.json,moduledict.json,能够有多个 "canvas_2": "base1.json" }, "nets_conn": [ //描述每一个Sequential内部的连通状况,base层没有该属性 "connection1.json", "connection2.json" ] } }
描述:一种封装的网络结构,多个相同的层封装在一块儿,注意其中的canvas只有一个网络
{ "type": "modulelist", "name": "multiple layers", //对于modulelist为用户在保存网络层时为网络层取的名字 "attribute": { //对于modulelist不须要指定in "canvas_%d": "sequential1.json", //这里能够是sequential.json或者base.json等,只能是一个 "num": 10 } }
描述:一种封装的网络结构,至关于一个多路选择器,从众多canvas中选择一个ide
{ "type": "moduledict", "name": "moduledict_1", //对于moduledict为用户在保存网络层时为网络层取的名字,默认在后面表序号 "attribute": { "default": "canvas_1", "choose": "canvas_2", //moduledict至关与一个多路选择器,有一个default路,和可选的canvas "nets": { "canvas_%d": "sequential1.json", //这里能够是sequential.json或者base.json等,能够有多个 "canvas_2": "base1.json" } } }
描述:静态变量。后续可能添加数据模块(数据加强,打乱等)学习
{ "epoch": 100, //全数据集训练次数 非0正数 "learning_rate": 0.01, //学习率 大于0的实数 "learning_rate_scheduler": { "name": "StepLR", "attribute": { "step_size": 50, "gamma": 0.1 } }, "device": "gpu", "data": "svhn", //mnist, cifar10, stl10, svhn等 "optimizer": { "name": "Adam", "attribute": { "momentum": 0.9 } }, //SGD, RMSprop, Adam "loss": { "name": "CrossEntropyLoss", "attribute": { "reduction":"mean" } }, "batch_size": 16 }
描述:前端最后给后端传的全部数据code
static = { "epoch": epoch, "learning_rate": learning_rate, "batch_size": batch_size, "learning_rate_scheduler":learning_rate_scheduler, "device":platform, "data":dataset, "optimizer":optimizer, "loss":loss }; structure = { "canvas": sequential, "static": static }; ret = { "name" : $("#model_name").val(), "structure":structure } //这个ret是传回后端的json格式,为了后端的向下兼容
{ "canvas": "sequential.json", "static": "static.json" }