通过Python文件在网络中添加新的Python层

来源:互联网 发布:npm 淘宝镜像 instal 编辑:程序博客网 时间:2024/06/14 05:37

在网络中添加dice.py作为一种新的度量方式。
对网络生成文件net.py进行修改。需要添加的层内容如下:

# Dice coefficientlayer {    type: 'Python'    name: 'dice'    bottom: 'score'    bottom: 'label'    top: 'dice'    python_param {      module: "dice"      layer: "Dice"    }    exclude { stage: "deploy" }}

net.py的层定义部分的最后(n.loss之后,return n.to_proto()之前)添加:

n.dice = L.Python(n.score, n.label, ntop = 1, python_param = dict(module = 'dice', layer = 'Dice'), exclude = dict(stage = 'deploy'))

其中n.dice中的dicetop的名字,L.Python表明是Python层,n.score, n.label说明bottom来自这两部分,ntop表明只有一个输出,即dice。这里写代码片python_param = dict(module = 'dice', layer = 'Dice'), exclude = dict(stage = 'deploy')为另外的参数。其中Dice应与dice.py中的类名同名。

基于FCN中voc-fcn32s的修改,其他部分相同。

0 0
原创粉丝点击