From 9241533fe2a8fdd44bf657e1af1564743cc89722 Mon Sep 17 00:00:00 2001 From: Mike Clift Date: Mon, 19 Jun 2023 17:11:18 +0100 Subject: [PATCH 1/2] Restore gensim import and w2v data load --- lessons/5-NLP/14-Embeddings/EmbeddingsTF.ipynb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lessons/5-NLP/14-Embeddings/EmbeddingsTF.ipynb b/lessons/5-NLP/14-Embeddings/EmbeddingsTF.ipynb index ffa4e533..c8e9c49c 100644 --- a/lessons/5-NLP/14-Embeddings/EmbeddingsTF.ipynb +++ b/lessons/5-NLP/14-Embeddings/EmbeddingsTF.ipynb @@ -292,6 +292,16 @@ "> **Note:** When you first create word vectors, downloading them can take some time!" ] }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [], + "source": [ + "import gensim.downloader as api\n", + "w2v = api.load('word2vec-google-news-300')" + ] + }, { "cell_type": "code", "execution_count": 12, From 4e8b11c2ce625d05f2865d2fa45121a8e7a0f7c5 Mon Sep 17 00:00:00 2001 From: Mike Clift Date: Mon, 19 Jun 2023 17:20:10 +0100 Subject: [PATCH 2/2] Replace index2word with index_to_key --- lessons/5-NLP/14-Embeddings/EmbeddingsTF.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lessons/5-NLP/14-Embeddings/EmbeddingsTF.ipynb b/lessons/5-NLP/14-Embeddings/EmbeddingsTF.ipynb index c8e9c49c..ccbecb75 100644 --- a/lessons/5-NLP/14-Embeddings/EmbeddingsTF.ipynb +++ b/lessons/5-NLP/14-Embeddings/EmbeddingsTF.ipynb @@ -419,7 +419,7 @@ "d = np.sum((w2v.vectors-qvec)**2,axis=1)\n", "min_idx = np.argmin(d)\n", "# find the corresponding word\n", - "w2v.index2word[min_idx]" + "w2v.index_to_key[min_idx]" ] }, {