Marie_Isa
Marie_Isa

Reputation: 47

Add dense output to convolution output

I want to include a label to a convolution operation in keras. Therefore I add an output of a dense layer to an output of a convolutional layer. See following code:

output_total = output_conv + output_dense

with shape(output_conv) = (?, 1024, 8) and shape(output_dense)= (?,1 , 1024)

--> seq_length is 1024 and nfilters is 8

The dense input is a one-hot vector and I want it to influence all 8 colums of the convolution output. So how do I repeat the dense colums of length 1024 for all the 8 times so that I can add it?

Thanks for your help in advance!

Upvotes: 0

Views: 45

Answers (1)

Marco Cerliani
Marco Cerliani

Reputation: 22031

you have to permute the dimension of the layer with shape (?,1,1024) and apply every operation you consider appropriate

here a dummy example

inp1 = Input((1024,8))
inp2 = Input((1,1024))
x = Add()([inp1,Permute((2,1))(inp2)])
model = Model([inp1, inp2], x)
model.summary()

Upvotes: 1

Related Questions