Skip to content

Commit 4ea2a68

Browse files
authored
Update Readme.md
1 parent 2a1c944 commit 4ea2a68

File tree

1 file changed

+1
-25
lines changed
  • Chapter-wise code/Code - PyTorch/6. Natural-Language-Processing/6. Machine Translation/NMT-Basic

1 file changed

+1
-25
lines changed

Chapter-wise code/Code - PyTorch/6. Natural-Language-Processing/6. Machine Translation/NMT-Basic/Readme.md

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,6 @@ Here, we have 3 given parameters:
1414

1515
Now, we have to create an English embedding matrix and French embedding matrix:<br>
1616
<img src="./images/en_fr_embeddings.png"></img><br>
17-
```python
18-
# loop through all english, french word pairs in the english french dictionary
19-
for en_word, fr_word in en_fr.items():
20-
21-
# check that the french word has an embedding and that the english word has an embedding
22-
if fr_word in french_set and en_word in english_set:
23-
24-
# get the english embedding
25-
en_vec = english_vecs[en_word]
26-
27-
# get the french embedding
28-
fr_vec = french_vecs[fr_word]
29-
30-
# add the english embedding to the list
31-
X_l.append(en_vec)
32-
33-
# add the french embedding to the list
34-
Y_l.append(fr_vec)
35-
36-
# stack the vectors of X_l into a matrix X
37-
X = np.vstack(X_l)
38-
39-
# stack the vectors of Y_l into a matrix Y
40-
Y = np.vstack(Y_l)
41-
```
4217

4318
## 2. Linear Transformation of Word Embeddings
4419
Given dictionaries of English and French word embeddings we will create a transformation matrix `R`. In other words, given an english word embedding, `e`, we need to multiply `e` with `R`, i.e., (`eR`) to generate a new word embedding `f`.
@@ -51,6 +26,7 @@ Original Forbenius Norm: <img src="./images/original_forbenius_norm.png"></img><
5126
Modified Forbenius Norm: <img src="./images/modified_forbenius_norm.png"></img><br>
5227
Finally, our loss funtion will look something like this:<br>
5328
<img src="./images/final_loss_function.png"></img><br>
29+
<img src="./images/description.png"></img>
5430

5531

5632

0 commit comments

Comments
 (0)