Skip to content

Commit 8dd0544

Browse files
committed
learning representations
1 parent 716df7f commit 8dd0544

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "8c4bcc08",
6+
"metadata": {},
7+
"source": [
8+
"## Learning Phrase Representations using RNN Encoder-Decoder for Statistical Machine Translation"
9+
]
10+
},
11+
{
12+
"cell_type": "markdown",
13+
"id": "f3b9f829",
14+
"metadata": {},
15+
"source": [
16+
"n this second notebook on sequence-to-sequence models using PyTorch and TorchText, we'll be implementing the model from [Learning Phrase Representations using RNN Encoder-Decoder for Statistical Machine Translation](https://arxiv.org/abs/1406.1078). This model will achieve improved test perplexity whilst only using a single layer RNN in both the encoder and the decoder."
17+
]
18+
},
19+
{
20+
"cell_type": "markdown",
21+
"id": "77ac8433",
22+
"metadata": {},
23+
"source": [
24+
" Refer [original notebook](https://github.com/bentrevett/pytorch-seq2seq/blob/master/2%20-%20Learning%20Phrase%20Representations%20using%20RNN%20Encoder-Decoder%20for%20Statistical%20Machine%20Translation.ipynb) for more details and explanation"
25+
]
26+
},
27+
{
28+
"cell_type": "markdown",
29+
"id": "8fc24434",
30+
"metadata": {},
31+
"source": [
32+
"## Preparing data"
33+
]
34+
},
35+
{
36+
"cell_type": "code",
37+
"execution_count": null,
38+
"id": "d286925b",
39+
"metadata": {},
40+
"outputs": [],
41+
"source": [
42+
"import torch\n",
43+
"import torch.nn as nn\n",
44+
"import torch.optim as optim\n",
45+
"\n",
46+
"from torchtext.legacy.datasets import Multi30k"
47+
]
48+
}
49+
],
50+
"metadata": {
51+
"kernelspec": {
52+
"display_name": "Python 3",
53+
"language": "python",
54+
"name": "python3"
55+
},
56+
"language_info": {
57+
"codemirror_mode": {
58+
"name": "ipython",
59+
"version": 3
60+
},
61+
"file_extension": ".py",
62+
"mimetype": "text/x-python",
63+
"name": "python",
64+
"nbconvert_exporter": "python",
65+
"pygments_lexer": "ipython3",
66+
"version": "3.7.10"
67+
}
68+
},
69+
"nbformat": 4,
70+
"nbformat_minor": 5
71+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Importing stuff
2+
import torch
3+
import torch.nn
4+
import torch.optim as optim
5+
6+
from torchtext.legacy.datasets import Multi30k
7+
from torchtext.legacy.data import Field, BucketIterator
8+
9+
import spacy
10+
import numpy as np
11+
12+
import random
13+
import math
14+
import time
15+
16+
# Setting SEED
17+
SEED = 1234
18+
19+
random.seed(SEED)
20+
np.random.seed(SEED)
21+
torch.manual_seed(SEED)
22+
torch.cuda.manual_seed(SEED)
23+
torch.backends.cudnn.deterministic = True
24+
25+
spacy_de = spacy.load('de_core_news_sm')
26+
spacy_en = spacy.load('en_core_web_sm')

0 commit comments

Comments
 (0)