How to implement merge layer of keras with mode as any user defined function
How to implement merge layer of keras with mode as any user defined function
I am trying to implement a paper on mixture of CNN expert and I need to add merge layers as weighted sum of each CNN's output where weight is the output of the gating network. So my mode is a custom defined function.
Here is the code I am trying to run:
def merge_mode(branches):
g, o1, o2, o3, o4 = branches
return K.transpose(K.transpose(o1)*g[:,0] + K.transpose(o2)*g[:,1] + K.transpose(o3)*g[:,2] + K.transpose(o4)*g[:,3])
model = Sequential()
model.add(merge([gate, model1, model2, model3, model4], output_shape=(3,), mode=merge_mode))
0
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.