0

나는 키보드를 caffe.NetSpec() 함수로 정의하는 단계를 밟고 있으며 프로그래밍에 익숙하지 않습니다.NetSpec()으로 Deconvolution 레이어 만들기 : SyntaxError

나는 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  
} 
} 
} 

이 함수 정의이다

File "./first_try.py", line 78 
    n.fc6-deconv=deconv_relu(n.fc7,512,ks=7) 
SyntaxError: can't assign to operator 
: 그것은 다음과 같은 오류를 도시 한 weight_filler와 'bias_filler'를 가산함으로써

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 

두 줄을 주석으로 처리 한 결과이 오류가 표시됩니다.

File "./first_try.py", line 18 
    param=[dict(lr_mult=1, decay_mult=1), dict(lr_mult=2, decay_mult=0)]]) 
     ^
SyntaxError: invalid syntax 

누군가 도와 드릴 수 있습니까?

덕분에 많은

답변

0

당신이 n.fc6 - deconv에 값을 할당하려고하기 때문에

n.fc6-deconv=deconv_relu(n.fc7,512,ks=7) 

는 관계없이 deconv_relu 구현의 당신에게 오류를 제공합니다 귀하의 라인 : 파이썬이 레이어에 대시 (-를) 해석 마이너스 연산자로 이름. 레이어의 새 이름을 선택해야합니다. "Deconvolution" 층 정의 caffeNetSpec()를 사용로서는

: convolution_paramdict (dict들과하지리스트)를 가져

deconv=L.Deconvolution(bottom, 
         convolution_param=dict(num_output=nout, 
               kernel_size=ks, 
               stride=stride, 
               pad=pad, 
               weight_filler=dict(type='gaussian', std=std), 
               bias_filler=dict(type= 'constant',value=0)), 
         param=[dict(lr_mult=1, decay_mult=1), dict(lr_mult=2, decay_mult=0)]]) 

하는 것으로를
weight_fillerbias_fillerconvolution_params에 전달 dict의 일부
paramdict입니다.