You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HI ,ALL
when I run keras/examples/pretrained_word_embeddings.py, it is ok. But,if i save this model like:
model.save('my_model.h5')
then I create a new py script and load model:
model = keras.models.load_model('my_model.h5')
a error raise: Invalid type for initial value: <class 'dict'>(expected python scalar,list or tuple of values or numpy )
the solution is that:
embedding_layer = Embedding(num_words,
EMBEDDING_DIM,
embeddings_initializer=Constant(embedding_matrix.tolist()),
input_length=MAX_SEQUENCE_LENGTH,
trainable=False)
modify Constant(embedding_matrix) to be Constant(embedding_matrix.tolist())
after that ,the model can be saved and reload.