在网络中添加dice.py
作为一种新的度量方式。
对网络生成文件net.py
进行修改。需要添加的层内容如下:
# Dice coefficient
layer {
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
中的dice
为top
的名字,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的修改,其他部分相同。