What has embedding changed most?

We can take the initial GloVe embedding and the final learned embedding and compare them by taking the norm of their difference for each word. Then, we can sort the norm values to see which words changed the most. Here is the code to do this:

learned_embeddings = amazon_review_model.get_classification_model()
.get_layer('embedding').get_weights()[0]

embd_change = {}
for word, i in preprocessor.word_index.items():
embd_change[word] = np.linalg.norm(initial_embeddings[i]-
learned_embeddings[i])
embd_change = sorted(embd_change.items(), key=lambda x: x[1],
reverse=True)
embd_change[0:20]

You can check that the most updated embedding are for the opinion words.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.49.182