0

私はcaffe.NetSpec()関数でネットワークを定義するための赤ちゃんの措置を講じるのですが、私はプログラミングの専門家ではありません。NetSpec()でデコンボリューション層を作成する:SyntaxError

でネットの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 

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 

​​と 'bias_filler' を追加することにより、それが次のエラーを示した以下になければならない層の定義であります

の2行をコメントアウトした後、このエラーが表示されます。

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

誰か助けてもらえますか?あなたはn.fc6 - deconvに値を代入しようとしているため

どうもありがとう

答えて

0

あなたのライン

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

は、関係なく、あなたのdeconv_relu実装のあなたにエラーを与える:Pythonは、あなたの層の中にダッシュ(-)を解釈しますマイナス演算子としての名前。レイヤーの新しい名前を選択する必要があります。 "Deconvolution"層定義するcaffeNetSpec()を使用するように

convolution_paramが(dict Sのリストではなく)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)]]) 

注、
​​とbias_fillerconvolution_paramsに渡さdictの一部であります
paramは、dictのリストです。

関連する問題