Skip to content

Commit a565390

Browse files
committed
lots of new stuff.
1 parent 49228be commit a565390

17 files changed

+2213
-181
lines changed

Part01_prerequisites.ipynb

Lines changed: 615 additions & 48 deletions
Large diffs are not rendered by default.

Part02_recurrent_neural_networks.ipynb

Lines changed: 1321 additions & 12 deletions
Large diffs are not rendered by default.

Part03_transformer.ipynb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,7 +1830,7 @@
18301830
},
18311831
{
18321832
"cell_type": "code",
1833-
"execution_count": 125,
1833+
"execution_count": 126,
18341834
"metadata": {
18351835
"slideshow": {
18361836
"slide_type": "skip"
@@ -1845,7 +1845,14 @@
18451845
},
18461846
{
18471847
"cell_type": "code",
1848-
"execution_count": 64,
1848+
"execution_count": null,
1849+
"metadata": {},
1850+
"outputs": [],
1851+
"source": []
1852+
},
1853+
{
1854+
"cell_type": "code",
1855+
"execution_count": 127,
18491856
"metadata": {
18501857
"slideshow": {
18511858
"slide_type": "skip"
@@ -1875,13 +1882,15 @@
18751882
},
18761883
"outputs": [],
18771884
"source": [
1878-
"from transformers import AdamW\n",
1885+
"from transformers import AdamW, BertForSequenceClassification\n",
18791886
"from transformers.optimization import WarmupLinearSchedule\n",
18801887
"\n",
18811888
"num_epochs = 5\n",
1889+
"bert = BertForSequenceClassification.from_pretrained('bert-base-multilingual-cased', num_labels=len(torch.unique(y_train)))\n",
18821890
"params = [p for n, p in bert.named_parameters()]\n",
18831891
"optimizer = AdamW(params, lr=3e-5, correct_bias=False)\n",
18841892
"\n",
1893+
"\n",
18851894
"num_total_steps = num_epochs * (len(train_dataloader.sampler) // batch_size)\n",
18861895
"num_warmup_steps = int(num_total_steps * 0.15)\n",
18871896
"scheduler = WarmupLinearSchedule(optimizer, warmup_steps=num_warmup_steps, t_total=num_total_steps)"

Pipfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ future = "*"
1616
graphviz = "*"
1717
matplotlib = "*"
1818
seaborn = "*"
19-
spacy = "*"
2019
rise = "*"
2120
jupyter-contrib-nbextensions = "*"
2221
transformers = "*"
2322
ipdb = "*"
2423
networkx = "*"
24+
torchtext = "*"
25+
spacy = "*"
26+
h5py = "*"
27+
fastai = "*"
2528

2629
[requires]
2730
python_version = "3.7"

Pipfile.lock

Lines changed: 259 additions & 115 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

RNN-unrolled.png

-92 KB
Binary file not shown.

clever_bert.jpg

-86.1 KB
Binary file not shown.

ferrari-miniature-red-35964.jpg

-128 KB
Binary file not shown.

finnish.jpg

-153 KB
Binary file not shown.

homer_cooking.gif

-687 KB
Binary file not shown.

homer_life_hard.gif

-493 KB
Binary file not shown.

homer_reading.gif

-445 KB
Binary file not shown.

kuusi_palaa.jpg

-56.9 KB
Binary file not shown.
-26.9 KB
Binary file not shown.

transformer_input.png

-64.1 KB
Binary file not shown.

transformer_overview.png

-133 KB
Binary file not shown.

utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import pandas as pd
22

33
def load_gnad():
4-
with open('./data/10kgnad/train.csv', 'r') as fh:
4+
with open('./train.csv', 'r') as fh:
55
data = (line.split(';', 1) for line in fh)
66
gnad_train = pd.DataFrame.from_records(data, columns=['category', 'text'])
77

8-
with open('./data/10kgnad/test.csv', 'r') as fh:
8+
with open('./test.csv', 'r') as fh:
99
data = (line.split(';', 1) for line in fh)
1010
gnad_test = pd.DataFrame.from_records(data, columns=['category', 'text'])
1111

0 commit comments

Comments
 (0)