私はtheanoバックエンド(これは既にTensorFlowバックエンド用に存在する)のSeparableConvolution2Dレイヤーに相当するものをエミュレートしようとしています。最初のステップとして、テンソルから次のレイヤーに1つのチャンネルを渡すだけです。ですから、形状を持つ出力を生成する16個のフィルタを持つconv1という2次元畳み込みレイヤーがあります。(batch_size、16、height、width)形状(:、0、:、:)でサブセンサーを選択し、次のレイヤー。十分に簡単ですか?テナーの個別チャネルをKerasのレイヤーに渡す
これは私のコードです:
from keras import backend as K
image_input = Input(batch_shape = (batch_size, 1, height, width), name = 'image_input')
conv1 = Convolution2D(16, 3, 3, name='conv1', activation = 'relu')(image_input)
conv2_input = K.reshape(conv1[:,0,:,:] , (batch_size, 1, height, width))
conv2 = Convolution2D(16, 3, 3, name='conv1', activation = 'relu')(conv2_input)
これはスロー:
Exception: You tried to call layer "conv1". This layer has no information about its expected input shape, and thus cannot be built. You can build it manually via: layer.build(batch_input_shape)
をなぜ層は、必要な形状情報を持っていませんか?私はtheanoバックエンドからの形を変えています。これは、個々のチャンネルを次のレイヤに渡す正しい方法ですか?
この回答が自己完結型であるように、リンクの関連部分を引用する必要があります。 –