from keras import layers as KL
def create_model():
inp = KL.Input(shape=(None,), name='input')
embedding = KL.Embedding(input_dim=10, output_dim=10)(inp)
out = KL.Dense(1, activation='sigmoid', name='dense')(embedding)
model = KM.Model(inputs=[inp], outputs=[out])
return model
model1 = create_model()
model1.summary()
model2 = create_model()
model2.summary()
The output for model1:
embedding_1 (Embedding)
model2:
embedding_2 (Embedding)
Why the name of the layer is not fixed? If I run create_model()
again, the name will be suffixed with _3
.
Any idea? Does this has anything to do with running in Jupyter? Does Jupyter kernel somehow cache the variables? Thanks!