August 2018
Intermediate to advanced
438 pages
12h 3m
English
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.
Read now
Unlock full access