如何在Keras中设置嵌入层名称

时间:2018-10-09 02:48:46

标签: python keras embedding

inputs_bedding = Input(shape=(it.shape))   
embedding = Embedding(9488, 512, trainable=False)(inputs_bedding)

keras嵌入层中没有name参数。如何为图层设置名称?

1 个答案:

答案 0 :(得分:0)

您可以像其他任何图层一样设置嵌入图层的名称。

from keras.layers import Embedding, Input
from keras import Model


inputs_bedding = Input(shape=(32,)) 
embedding = Embedding(9488, 512, trainable=False, name="test")(inputs_bedding)

model = Model(inputs=inputs_bedding, outputs=embedding)

model.summary()为您提供:

_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
input_3 (InputLayer)         (None, 32)                0         
_________________________________________________________________
test (Embedding)             (None, 32, 512)           4857856   
=================================================================
Total params: 4,857,856
Trainable params: 0
Non-trainable params: 4,857,856
_________________________________________________________________