【发布时间】:2018-04-12 14:05:34
【问题描述】:
我正在逐步通过caffe.NetSpec() 函数定义网络,我不是编程专家。
我正在定义一个函数,由NetSpec 为网络创建Deconvolution 层。下面是层定义应该是:
layer {
name: "deconv1"
type: "Deconvolution"
bottom: "bottom1"
top: "top1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 512
kernel_size: 7
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
这是函数定义:
def deconv_relu(bottom,nout,ks=3,stride=1,pad=1,std=0.01):
deconv=L.Deconvolution(bottom,
convolution_param=[dict(num_output=nout, kernel_size=ks, stride=stride, pad=pad),
param=[dict(lr_mult=1, decay_mult=1), dict(lr_mult=2, decay_mult=0)]])
## weight_filler=dict(type= 'gaussian', std=std),
## bias_filler=dict(type= 'constant',value=0))
return deconv
通过添加 weight_filler 和 'bias_filler' ,它显示以下错误:
File "./first_try.py", line 78
n.fc6-deconv=deconv_relu(n.fc7,512,ks=7)
SyntaxError: can't assign to operator
在注释掉这两行之后,它显示了这个错误:
File "./first_try.py", line 18
param=[dict(lr_mult=1, decay_mult=1), dict(lr_mult=2, decay_mult=0)]])
^
SyntaxError: invalid syntax
有人可以帮忙吗?
非常感谢
【问题讨论】:
标签: neural-network computer-vision caffe conv-neural-network pycaffe