画像データを分割するためにConvNetを使用したいと思います。同じネットワークに異なるデータ(しかし非常に似ている)を供給しなければならない場合、出力をマージする必要があります。ケラス:重みの共有が機能しません
私のデータは3Dです。私はそれを2D画像にスライスし、TimeDistributed
経由でConvNetに渡します。
画像に同じConvNetを使用することが重要です。重みは共有する必要があります。
dim_x, dim_y, dim_z = 40, 40, 40
inputs = Input((1, dim_x, dim_y, dim_z))
# slice the volume along different axes
x_perm=Permute((2,1,3,4))(inputs)
y_perm=Permute((3,1,2,4))(inputs)
z_perm=Permute((4,1,2,3))(inputs)
#apply the segmentation to each layer and for each slice-direction
x_dist=TimeDistributed(convmodel)(x_perm)
y_dist=TimeDistributed(convmodel)(y_perm)
z_dist=TimeDistributed(convmodel)(z_perm)
# now undo the permutation
x_dist=Permute((2,1,3,4))(x_dist)
y_dist=Permute((2,3,1,4))(y_dist)
z_dist=Permute((2,3,4,1))(z_dist)
#now merge the predictions
segmentation=merge([x_dist, y_dist, z_dist], mode="concat")
temp_model=Model(input=inputs, output=segmentation)
temp_model.summary()
convnetモデルはおよそ330万のパラメータがあります。 は、ここでは、コードです。順列とTimeDistributedレイヤーには独自のパラメータがありません。 したがって、完全なモデルは、convnetと同じ量のパラメータを持つ必要があります。
3倍多くのパラメータがあります。約990万回です。
明らかに重みは共有されません。 しかしこれは体重分担が働くことになっているwayです。
モデルは重みを共有し、パラメータの数が間違ってレポートされますか? ウェイト共有を有効にするにはセットアップを変更する必要がありますか? Keras-ユーザーGoogleグループへ