2024-04-20 04:17:51 发布
网友
我想用以下形式训练具有共享层的模型:
x --> F(x) ==> G(F(x),F(y)) y --> F(y)
x和{}是两个独立的输入层,F是共享层。G是连接F(x)和F(y)后的最后一层。在
x
F
G
F(x)
F(y)
有没有可能在Keras中建模?怎样?在
您可以为此使用Keras functional API:
from keras.layers import Input, concatenate x = Input(shape=...) y = Input(shape=...) shared_layer = MySharedLayer(...) out_x = shared_layer(x) out_y = shared_layer(y) concat = concatenate([out_x, out_y]) # pass concat to other layers ...
注意,x和{}可以是任何层的输出张量,而不一定是输入层。在
您可以为此使用Keras functional API:
注意,}可以是任何层的输出张量,而不一定是输入层。在
x
和{相关问题 更多 >
编程相关推荐