我想让一个网络接受多个输入,将它们堆叠起来并以argmax-ed层作为输出。这是我做的:
#iplusn : 8 x 32 x 32 x 6 tensor
# L:keras.layers
# B:keras.Backend
f0 = Feature(iplusn[0]) #each f gives 8 x 8 x 256
f1 = Feature(iplusn[1])
f2 = Feature(iplusn[2])
f3 = Feature(iplusn[3])
f4 = Feature(iplusn[4])
f5 = Feature(iplusn[5])
f6 = Feature(iplusn[6])
f7 = Feature(iplusn[7])
f_all = L.Lambda(lambda
x:B.stack((f0,f1,f2,f3,f4,f5,f6,f7),0))(x)
f_max = L.Lambda(lambda x:B.max(f_all,0))(x)
# I want f_all to be 8x8x8x256
# and f_max to be 8x8x256
x=L.Flatten()(f_max)
x = L.Dense(512)(x)
x = L.Dense(256)(x)
x = L.Dense(256)(x)
x = L.Dense(3)(x)
x_norm = L.Lambda(lambda x: B.l2_normalize(x, -1))(x)
在这里,我正在苦苦挣扎如何将lambda调整为堆栈功能,因为没有lambda,就无法对其进行训练。
请给我和指导,非常感谢。