TovaHasi commited on
Commit
c0a4460
1 Parent(s): 40924e1

Delete Train.ipynb

Browse files
Files changed (1) hide show
  1. Train.ipynb +0 -985
Train.ipynb DELETED
@@ -1,985 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": 1,
6
- "id": "3ece795d",
7
- "metadata": {
8
- "cellId": "icbn5fcdkdjmv2xo6f1uym"
9
- },
10
- "outputs": [],
11
- "source": [
12
- "#!g1.1\n",
13
- "from sklearn.preprocessing import LabelEncoder\n",
14
- "import transformers\n",
15
- "import torch\n",
16
- "import nltk\n",
17
- "import numpy as np\n",
18
- "import pandas as pd"
19
- ]
20
- },
21
- {
22
- "cell_type": "code",
23
- "execution_count": 2,
24
- "id": "2383e35c",
25
- "metadata": {
26
- "cellId": "r7277d47zkhjj04zr4od8g"
27
- },
28
- "outputs": [
29
- {
30
- "data": {
31
- "application/vnd.jupyter.widget-view+json": {
32
- "model_id": "a3fbc0c0072b4198bb84d870b39a6c74",
33
- "version_major": 2,
34
- "version_minor": 0
35
- },
36
- "text/plain": [
37
- "HBox(children=(FloatProgress(value=0.0, description='Downloading', max=1202.0, style=ProgressStyle(description…"
38
- ]
39
- },
40
- "metadata": {},
41
- "output_type": "display_data"
42
- },
43
- {
44
- "name": "stdout",
45
- "output_type": "stream",
46
- "text": [
47
- "\n"
48
- ]
49
- },
50
- {
51
- "name": "stderr",
52
- "output_type": "stream",
53
- "text": [
54
- "Using custom data configuration default\n"
55
- ]
56
- },
57
- {
58
- "name": "stdout",
59
- "output_type": "stream",
60
- "text": [
61
- "Downloading and preparing dataset json/default-71bc0cd49f840871 (download: Unknown size, generated: Unknown size, post-processed: Unknown size, total: Unknown size) to /tmp/xdg_cache/huggingface/datasets/json/default-71bc0cd49f840871/0.0.0/70d89ed4db1394f028c651589fcab6d6b28dddcabbe39d3b21b4d41f9a708514...\n"
62
- ]
63
- },
64
- {
65
- "data": {
66
- "application/vnd.jupyter.widget-view+json": {
67
- "model_id": "f8063733bbb9475babf7469daf6e7d56",
68
- "version_major": 2,
69
- "version_minor": 0
70
- },
71
- "text/plain": [
72
- "HBox(children=(FloatProgress(value=1.0, bar_style='info', layout=Layout(width='20px'), max=1.0), HTML(value=''…"
73
- ]
74
- },
75
- "metadata": {},
76
- "output_type": "display_data"
77
- },
78
- {
79
- "data": {
80
- "application/vnd.jupyter.widget-view+json": {
81
- "model_id": "f3df0e8c4d2a48968429ac5320020316",
82
- "version_major": 2,
83
- "version_minor": 0
84
- },
85
- "text/plain": [
86
- "HBox(children=(FloatProgress(value=1.0, bar_style='info', layout=Layout(width='20px'), max=1.0), HTML(value=''…"
87
- ]
88
- },
89
- "metadata": {},
90
- "output_type": "display_data"
91
- },
92
- {
93
- "data": {
94
- "application/vnd.jupyter.widget-view+json": {
95
- "model_id": "71a715a43bcd4f4a859c247b1f375e51",
96
- "version_major": 2,
97
- "version_minor": 0
98
- },
99
- "text/plain": [
100
- "HBox(children=(FloatProgress(value=1.0, bar_style='info', layout=Layout(width='20px'), max=1.0), HTML(value=''…"
101
- ]
102
- },
103
- "metadata": {},
104
- "output_type": "display_data"
105
- },
106
- {
107
- "name": "stdout",
108
- "output_type": "stream",
109
- "text": [
110
- "Dataset json downloaded and prepared to /tmp/xdg_cache/huggingface/datasets/json/default-71bc0cd49f840871/0.0.0/70d89ed4db1394f028c651589fcab6d6b28dddcabbe39d3b21b4d41f9a708514. Subsequent calls will reuse this data.\n"
111
- ]
112
- }
113
- ],
114
- "source": [
115
- "#!g1.1\n",
116
- "from datasets import load_dataset\n",
117
- "\n",
118
- "dataset_train_test_val = load_dataset('json', \n",
119
- " data_files={'train': 'train_dataset.json', 'test': 'test_dataset.json', 'val': 'val_dataset.json'})"
120
- ]
121
- },
122
- {
123
- "cell_type": "code",
124
- "execution_count": 3,
125
- "id": "5affcf2d",
126
- "metadata": {
127
- "cellId": "d3dqrbyaerahlxtoqhusl"
128
- },
129
- "outputs": [
130
- {
131
- "data": {
132
- "text/plain": [
133
- "DatasetDict({\n",
134
- " train: Dataset({\n",
135
- " features: ['labels', 'input_ids', 'attention_mask'],\n",
136
- " num_rows: 44928\n",
137
- " })\n",
138
- " test: Dataset({\n",
139
- " features: ['labels', 'input_ids', 'attention_mask'],\n",
140
- " num_rows: 11981\n",
141
- " })\n",
142
- " val: Dataset({\n",
143
- " features: ['labels', 'input_ids', 'attention_mask'],\n",
144
- " num_rows: 14976\n",
145
- " })\n",
146
- "})"
147
- ]
148
- },
149
- "execution_count": 3,
150
- "metadata": {},
151
- "output_type": "execute_result"
152
- }
153
- ],
154
- "source": [
155
- "#!g1.1\n",
156
- "dataset_train_test_val"
157
- ]
158
- },
159
- {
160
- "cell_type": "code",
161
- "execution_count": 4,
162
- "id": "1a1956c6",
163
- "metadata": {
164
- "cellId": "iv6a51fd9tlbrs4he3kizo"
165
- },
166
- "outputs": [],
167
- "source": [
168
- "#!g1.1\n",
169
- "train_dataset = dataset_train_test_val['train']\n",
170
- "val_dataset = dataset_train_test_val['val']\n",
171
- "test_dataset = dataset_train_test_val['test']"
172
- ]
173
- },
174
- {
175
- "cell_type": "code",
176
- "execution_count": 5,
177
- "id": "c161630b",
178
- "metadata": {
179
- "cellId": "t9fridyqfq20q78rkgitt"
180
- },
181
- "outputs": [],
182
- "source": [
183
- "#!g1.1\n",
184
- "train_dataset.set_format(\"torch\")\n",
185
- "val_dataset.set_format(\"torch\")\n",
186
- "test_dataset.set_format(\"torch\")"
187
- ]
188
- },
189
- {
190
- "cell_type": "code",
191
- "execution_count": 6,
192
- "id": "7ee3ce1c",
193
- "metadata": {
194
- "cellId": "1y1jaan8t8gjs3masmvulu"
195
- },
196
- "outputs": [
197
- {
198
- "data": {
199
- "application/vnd.jupyter.widget-view+json": {
200
- "model_id": "4144d1c375104f64a4376b44dc68167a",
201
- "version_major": 2,
202
- "version_minor": 0
203
- },
204
- "text/plain": [
205
- "HBox(children=(FloatProgress(value=0.0, description='Downloading', max=1248.0, style=ProgressStyle(description…"
206
- ]
207
- },
208
- "metadata": {},
209
- "output_type": "display_data"
210
- },
211
- {
212
- "name": "stdout",
213
- "output_type": "stream",
214
- "text": [
215
- "\n"
216
- ]
217
- }
218
- ],
219
- "source": [
220
- "#!g1.1\n",
221
- "from datasets import load_metric\n",
222
- "\n",
223
- "metric = load_metric(\"accuracy\")\n",
224
- "def compute_metrics(eval_pred):\n",
225
- " logits, labels = eval_pred\n",
226
- " predictions = np.argmax(logits, axis=-1)\n",
227
- " return metric.compute(predictions=predictions, references=labels)"
228
- ]
229
- },
230
- {
231
- "cell_type": "code",
232
- "execution_count": 7,
233
- "id": "c5d12dc8",
234
- "metadata": {
235
- "cellId": "6eds6is9lek1hcs87cizgy"
236
- },
237
- "outputs": [
238
- {
239
- "data": {
240
- "application/vnd.jupyter.widget-view+json": {
241
- "model_id": "4de02bce2bd448efa4d6e7c1e02c427a",
242
- "version_major": 2,
243
- "version_minor": 0
244
- },
245
- "text/plain": [
246
- "HBox(children=(FloatProgress(value=0.0, description='Downloading', max=483.0, style=ProgressStyle(description_…"
247
- ]
248
- },
249
- "metadata": {},
250
- "output_type": "display_data"
251
- },
252
- {
253
- "name": "stdout",
254
- "output_type": "stream",
255
- "text": [
256
- "\n"
257
- ]
258
- },
259
- {
260
- "data": {
261
- "application/vnd.jupyter.widget-view+json": {
262
- "model_id": "e8f550b59f4b418094cbcb1d13c5dd97",
263
- "version_major": 2,
264
- "version_minor": 0
265
- },
266
- "text/plain": [
267
- "HBox(children=(FloatProgress(value=0.0, description='Downloading', max=267967963.0, style=ProgressStyle(descri…"
268
- ]
269
- },
270
- "metadata": {},
271
- "output_type": "display_data"
272
- },
273
- {
274
- "name": "stdout",
275
- "output_type": "stream",
276
- "text": [
277
- "\n"
278
- ]
279
- },
280
- {
281
- "name": "stderr",
282
- "output_type": "stream",
283
- "text": [
284
- "Some weights of the model checkpoint at distilbert-base-uncased were not used when initializing DistilBertForSequenceClassification: ['vocab_layer_norm.weight', 'vocab_projector.weight', 'vocab_projector.bias', 'vocab_transform.bias', 'vocab_layer_norm.bias', 'vocab_transform.weight']\n",
285
- "- This IS expected if you are initializing DistilBertForSequenceClassification from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).\n",
286
- "- This IS NOT expected if you are initializing DistilBertForSequenceClassification from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).\n",
287
- "Some weights of DistilBertForSequenceClassification were not initialized from the model checkpoint at distilbert-base-uncased and are newly initialized: ['classifier.weight', 'pre_classifier.weight', 'classifier.bias', 'pre_classifier.bias']\n",
288
- "You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.\n"
289
- ]
290
- }
291
- ],
292
- "source": [
293
- "#!g1.1\n",
294
- "from transformers import Trainer, TrainingArguments, AutoModelForSequenceClassification\n",
295
- "\n",
296
- "device = \"cuda:0\" if torch.cuda.is_available() else \"cpu\"\n",
297
- "\n",
298
- "model = AutoModelForSequenceClassification.from_pretrained(\"distilbert-base-uncased\", num_labels=8)\n",
299
- "model = model.to(device)\n",
300
- "\n",
301
- "trainer = Trainer(\n",
302
- " model=model, \n",
303
- " train_dataset=train_dataset, \n",
304
- " eval_dataset=val_dataset,\n",
305
- " compute_metrics=compute_metrics,\n",
306
- " args=TrainingArguments(\n",
307
- " output_dir=\"./my_saved_model\", overwrite_output_dir=True,\n",
308
- " num_train_epochs=4, per_device_train_batch_size=32,\n",
309
- " save_steps=10000, save_total_limit=2),\n",
310
- ")"
311
- ]
312
- },
313
- {
314
- "cell_type": "code",
315
- "execution_count": 13,
316
- "id": "59b4c995",
317
- "metadata": {
318
- "cellId": "enykeyqh04h85cnkvsnyvr"
319
- },
320
- "outputs": [
321
- {
322
- "name": "stderr",
323
- "output_type": "stream",
324
- "text": [
325
- "***** Running training *****\n",
326
- " Num examples = 44928\n",
327
- " Num Epochs = 4\n",
328
- " Instantaneous batch size per device = 32\n",
329
- " Total train batch size (w. parallel, distributed & accumulation) = 32\n",
330
- " Gradient Accumulation steps = 1\n",
331
- " Total optimization steps = 5616\n"
332
- ]
333
- },
334
- {
335
- "data": {
336
- "text/html": [
337
- "\n",
338
- " <div>\n",
339
- " \n",
340
- " <progress value='5616' max='5616' style='width:300px; height:20px; vertical-align: middle;'></progress>\n",
341
- " [5616/5616 53:29, Epoch 4/4]\n",
342
- " </div>\n",
343
- " <table border=\"1\" class=\"dataframe\">\n",
344
- " <thead>\n",
345
- " <tr style=\"text-align: left;\">\n",
346
- " <th>Step</th>\n",
347
- " <th>Training Loss</th>\n",
348
- " </tr>\n",
349
- " </thead>\n",
350
- " <tbody>\n",
351
- " <tr>\n",
352
- " <td>500</td>\n",
353
- " <td>0.068200</td>\n",
354
- " </tr>\n",
355
- " <tr>\n",
356
- " <td>1000</td>\n",
357
- " <td>0.065100</td>\n",
358
- " </tr>\n",
359
- " <tr>\n",
360
- " <td>1500</td>\n",
361
- " <td>0.069500</td>\n",
362
- " </tr>\n",
363
- " <tr>\n",
364
- " <td>2000</td>\n",
365
- " <td>0.064600</td>\n",
366
- " </tr>\n",
367
- " <tr>\n",
368
- " <td>2500</td>\n",
369
- " <td>0.070400</td>\n",
370
- " </tr>\n",
371
- " <tr>\n",
372
- " <td>3000</td>\n",
373
- " <td>0.069800</td>\n",
374
- " </tr>\n",
375
- " <tr>\n",
376
- " <td>3500</td>\n",
377
- " <td>0.066200</td>\n",
378
- " </tr>\n",
379
- " <tr>\n",
380
- " <td>4000</td>\n",
381
- " <td>0.070000</td>\n",
382
- " </tr>\n",
383
- " <tr>\n",
384
- " <td>4500</td>\n",
385
- " <td>0.060200</td>\n",
386
- " </tr>\n",
387
- " <tr>\n",
388
- " <td>5000</td>\n",
389
- " <td>0.064800</td>\n",
390
- " </tr>\n",
391
- " <tr>\n",
392
- " <td>5500</td>\n",
393
- " <td>0.072600</td>\n",
394
- " </tr>\n",
395
- " </tbody>\n",
396
- "</table><p>"
397
- ],
398
- "text/plain": [
399
- "<IPython.core.display.HTML object>"
400
- ]
401
- },
402
- "metadata": {},
403
- "output_type": "display_data"
404
- },
405
- {
406
- "name": "stderr",
407
- "output_type": "stream",
408
- "text": [
409
- "\n",
410
- "\n",
411
- "Training completed. Do not forget to share your model on huggingface.co/models =)\n",
412
- "\n",
413
- "\n"
414
- ]
415
- },
416
- {
417
- "data": {
418
- "text/plain": [
419
- "TrainOutput(global_step=5616, training_loss=0.06720576955382301, metrics={'train_runtime': 3209.8809, 'train_samples_per_second': 55.987, 'train_steps_per_second': 1.75, 'total_flos': 2.380852842253517e+16, 'train_loss': 0.06720576955382301, 'epoch': 4.0})"
420
- ]
421
- },
422
- "execution_count": 13,
423
- "metadata": {},
424
- "output_type": "execute_result"
425
- },
426
- {
427
- "name": "stderr",
428
- "output_type": "stream",
429
- "text": [
430
- "/kernel/lib/python3.8/site-packages/ml_kernel/kernel.py:872: UserWarning: The following variables cannot be serialized: trainer\n",
431
- " warnings.warn(message)\n"
432
- ]
433
- }
434
- ],
435
- "source": [
436
- "#!g1.1\n",
437
- "trainer.train()"
438
- ]
439
- },
440
- {
441
- "cell_type": "code",
442
- "execution_count": 47,
443
- "id": "930c6dfc",
444
- "metadata": {
445
- "cellId": "sqt27hulgn6e3st0pa1jx"
446
- },
447
- "outputs": [
448
- {
449
- "name": "stderr",
450
- "output_type": "stream",
451
- "text": [
452
- "***** Running Evaluation *****\n",
453
- " Num examples = 14976\n",
454
- " Batch size = 8\n"
455
- ]
456
- },
457
- {
458
- "data": {
459
- "text/plain": [
460
- "{'eval_loss': 0.5749701261520386,\n",
461
- " 'eval_accuracy': 0.8629807692307693,\n",
462
- " 'eval_runtime': 122.7376,\n",
463
- " 'eval_samples_per_second': 122.016,\n",
464
- " 'eval_steps_per_second': 15.252,\n",
465
- " 'epoch': 4.0}"
466
- ]
467
- },
468
- "execution_count": 47,
469
- "metadata": {},
470
- "output_type": "execute_result"
471
- },
472
- {
473
- "name": "stderr",
474
- "output_type": "stream",
475
- "text": [
476
- "/kernel/lib/python3.8/site-packages/ml_kernel/kernel.py:872: UserWarning: The following variables cannot be serialized: trainer\n",
477
- " warnings.warn(message)\n"
478
- ]
479
- }
480
- ],
481
- "source": [
482
- "#!g1.1\n",
483
- "trainer.evaluate()"
484
- ]
485
- },
486
- {
487
- "cell_type": "code",
488
- "execution_count": 48,
489
- "id": "4ef33ef9",
490
- "metadata": {
491
- "cellId": "jizblzfc2jjq76b0kfppy"
492
- },
493
- "outputs": [
494
- {
495
- "name": "stderr",
496
- "output_type": "stream",
497
- "text": [
498
- "loading configuration file https://huggingface.co/distilbert-base-uncased/resolve/main/config.json from cache at /tmp/xdg_cache/huggingface/transformers/23454919702d26495337f3da04d1655c7ee010d5ec9d77bdb9e399e00302c0a1.91b885ab15d631bf9cee9dc9d25ece0afd932f2f5130eba28f2055b2220c0333\n",
499
- "Model config DistilBertConfig {\n",
500
- " \"_name_or_path\": \"distilbert-base-uncased\",\n",
501
- " \"activation\": \"gelu\",\n",
502
- " \"architectures\": [\n",
503
- " \"DistilBertForMaskedLM\"\n",
504
- " ],\n",
505
- " \"attention_dropout\": 0.1,\n",
506
- " \"dim\": 768,\n",
507
- " \"dropout\": 0.1,\n",
508
- " \"hidden_dim\": 3072,\n",
509
- " \"initializer_range\": 0.02,\n",
510
- " \"max_position_embeddings\": 512,\n",
511
- " \"model_type\": \"distilbert\",\n",
512
- " \"n_heads\": 12,\n",
513
- " \"n_layers\": 6,\n",
514
- " \"pad_token_id\": 0,\n",
515
- " \"qa_dropout\": 0.1,\n",
516
- " \"seq_classif_dropout\": 0.2,\n",
517
- " \"sinusoidal_pos_embds\": false,\n",
518
- " \"tie_weights_\": true,\n",
519
- " \"transformers_version\": \"4.17.0\",\n",
520
- " \"vocab_size\": 30522\n",
521
- "}\n",
522
- "\n",
523
- "loading file https://huggingface.co/distilbert-base-uncased/resolve/main/vocab.txt from cache at /tmp/xdg_cache/huggingface/transformers/0e1bbfda7f63a99bb52e3915dcf10c3c92122b827d92eb2d34ce94ee79ba486c.d789d64ebfe299b0e416afc4a169632f903f693095b4629a7ea271d5a0cf2c99\n",
524
- "loading file https://huggingface.co/distilbert-base-uncased/resolve/main/tokenizer.json from cache at /tmp/xdg_cache/huggingface/transformers/75abb59d7a06f4f640158a9bfcde005264e59e8d566781ab1415b139d2e4c603.7f2721073f19841be16f41b0a70b600ca6b880c8f3df6f3535cbc704371bdfa4\n",
525
- "loading file https://huggingface.co/distilbert-base-uncased/resolve/main/added_tokens.json from cache at None\n",
526
- "loading file https://huggingface.co/distilbert-base-uncased/resolve/main/special_tokens_map.json from cache at None\n",
527
- "loading file https://huggingface.co/distilbert-base-uncased/resolve/main/tokenizer_config.json from cache at /tmp/xdg_cache/huggingface/transformers/8c8624b8ac8aa99c60c912161f8332de003484428c47906d7ff7eb7f73eecdbb.20430bd8e10ef77a7d2977accefe796051e01bc2fc4aa146bc862997a1a15e79\n",
528
- "loading configuration file https://huggingface.co/distilbert-base-uncased/resolve/main/config.json from cache at /tmp/xdg_cache/huggingface/transformers/23454919702d26495337f3da04d1655c7ee010d5ec9d77bdb9e399e00302c0a1.91b885ab15d631bf9cee9dc9d25ece0afd932f2f5130eba28f2055b2220c0333\n",
529
- "Model config DistilBertConfig {\n",
530
- " \"_name_or_path\": \"distilbert-base-uncased\",\n",
531
- " \"activation\": \"gelu\",\n",
532
- " \"architectures\": [\n",
533
- " \"DistilBertForMaskedLM\"\n",
534
- " ],\n",
535
- " \"attention_dropout\": 0.1,\n",
536
- " \"dim\": 768,\n",
537
- " \"dropout\": 0.1,\n",
538
- " \"hidden_dim\": 3072,\n",
539
- " \"initializer_range\": 0.02,\n",
540
- " \"max_position_embeddings\": 512,\n",
541
- " \"model_type\": \"distilbert\",\n",
542
- " \"n_heads\": 12,\n",
543
- " \"n_layers\": 6,\n",
544
- " \"pad_token_id\": 0,\n",
545
- " \"qa_dropout\": 0.1,\n",
546
- " \"seq_classif_dropout\": 0.2,\n",
547
- " \"sinusoidal_pos_embds\": false,\n",
548
- " \"tie_weights_\": true,\n",
549
- " \"transformers_version\": \"4.17.0\",\n",
550
- " \"vocab_size\": 30522\n",
551
- "}\n",
552
- "\n"
553
- ]
554
- }
555
- ],
556
- "source": [
557
- "#!g1.1\n",
558
- "from transformers import AutoTokenizer\n",
559
- "\n",
560
- "tokenizer = AutoTokenizer.from_pretrained(\"distilbert-base-uncased\")"
561
- ]
562
- },
563
- {
564
- "cell_type": "code",
565
- "execution_count": 40,
566
- "id": "8d8db99a",
567
- "metadata": {
568
- "cellId": "n92sgrt3hao4qyq6sxedcn"
569
- },
570
- "outputs": [],
571
- "source": [
572
- "#!g1.1\n",
573
- "dict_label = {'math': 3,\n",
574
- " 'physics': 4,\n",
575
- " 'q-bio': 5,\n",
576
- " 'cs': 0,\n",
577
- " 'q-fin': 6,\n",
578
- " 'stat': 7,\n",
579
- " 'eess': 2,\n",
580
- " 'econ': 1}"
581
- ]
582
- },
583
- {
584
- "cell_type": "code",
585
- "execution_count": 41,
586
- "id": "fdbdddec",
587
- "metadata": {
588
- "cellId": "fr2cvkd1hljgj72kq6zja"
589
- },
590
- "outputs": [
591
- {
592
- "data": {
593
- "text/plain": [
594
- "{3: 'math',\n",
595
- " 4: 'physics',\n",
596
- " 5: 'q-bio',\n",
597
- " 0: 'cs',\n",
598
- " 6: 'q-fin',\n",
599
- " 7: 'stat',\n",
600
- " 2: 'eess',\n",
601
- " 1: 'econ'}"
602
- ]
603
- },
604
- "execution_count": 41,
605
- "metadata": {},
606
- "output_type": "execute_result"
607
- }
608
- ],
609
- "source": [
610
- "#!g1.1\n",
611
- "inv_map = {v: k for k, v in dict_label.items()}\n",
612
- "inv_map"
613
- ]
614
- },
615
- {
616
- "cell_type": "code",
617
- "execution_count": 99,
618
- "id": "029703f7",
619
- "metadata": {
620
- "cellId": "u0seb2c1ukrj9n8fdlh"
621
- },
622
- "outputs": [
623
- {
624
- "data": {
625
- "text/plain": [
626
- "array([1.15543455e-02, 2.51640333e-03, 2.27772980e-03, 9.46712017e-01,\n",
627
- " 4.27448237e-03, 8.11084581e-04, 2.39739451e-03, 2.94565000e-02],\n",
628
- " dtype=float32)"
629
- ]
630
- },
631
- "execution_count": 99,
632
- "metadata": {},
633
- "output_type": "execute_result"
634
- },
635
- {
636
- "name": "stderr",
637
- "output_type": "stream",
638
- "text": [
639
- "/kernel/lib/python3.8/site-packages/ml_kernel/kernel.py:872: UserWarning: The following variables cannot be serialized: trainer\n",
640
- " warnings.warn(message)\n"
641
- ]
642
- }
643
- ],
644
- "source": [
645
- "#!g1.1\n",
646
- "text = \"\"\"mathematics\"\"\"\n",
647
- "tokens = tokenizer.encode(text)\n",
648
- "with torch.no_grad():\n",
649
- " logits = model(torch.as_tensor([tokens], device=device))[0]\n",
650
- " probs = torch.softmax(logits[-1, :], dim=-1).data.cpu().numpy()\n",
651
- "probs"
652
- ]
653
- },
654
- {
655
- "cell_type": "code",
656
- "execution_count": 100,
657
- "id": "e7997e90",
658
- "metadata": {
659
- "cellId": "0xkwtgvl4kugzdw4d5ce4u"
660
- },
661
- "outputs": [
662
- {
663
- "name": "stdout",
664
- "output_type": "stream",
665
- "text": [
666
- "[0.946712, 0.0294565]\n",
667
- "['math', 'stat']\n"
668
- ]
669
- }
670
- ],
671
- "source": [
672
- "#!g1.1\n",
673
- "idx_label = np.argsort(probs)[::-1]\n",
674
- "\n",
675
- "sum_probs = 0\n",
676
- "prediction_probs = []\n",
677
- "prediction_classes = []\n",
678
- "\n",
679
- "idx = 0\n",
680
- "while sum_probs < 0.95:\n",
681
- " cur_predict = inv_map[idx_label[idx]]\n",
682
- " cur_probs = probs[idx_label[idx]]\n",
683
- " \n",
684
- " sum_probs += cur_probs\n",
685
- " \n",
686
- " prediction_probs.append(cur_probs)\n",
687
- " prediction_classes.append(cur_predict)\n",
688
- " \n",
689
- " idx += 1\n",
690
- "\n",
691
- "print(prediction_probs)\n",
692
- "print(prediction_classes)"
693
- ]
694
- },
695
- {
696
- "cell_type": "code",
697
- "execution_count": 117,
698
- "id": "eb1554c2",
699
- "metadata": {
700
- "cellId": "db2fcd21obqf3e3atfpa9"
701
- },
702
- "outputs": [],
703
- "source": [
704
- "#!g1.1\n",
705
- "def predict_label(title, summary, tokenizer, model, inv_map):\n",
706
- " abstract = title.lower() + '. ' + summary.lower()\n",
707
- " token_text = tokenizer.encode(abstract)\n",
708
- " \n",
709
- " with torch.no_grad():\n",
710
- " logits = model(torch.as_tensor([token_text], device=device))[0]\n",
711
- " probs = torch.softmax(logits[-1, :], dim=-1).data.cpu().numpy()\n",
712
- " \n",
713
- " idx_label = np.argsort(probs)[::-1]\n",
714
- "\n",
715
- " sum_probs = 0\n",
716
- " prediction_probs = []\n",
717
- " prediction_classes = []\n",
718
- "\n",
719
- " idx = 0\n",
720
- " while sum_probs < 0.95:\n",
721
- " cur_predict = inv_map[idx_label[idx]]\n",
722
- " cur_probs = probs[idx_label[idx]]\n",
723
- " \n",
724
- " sum_probs += cur_probs\n",
725
- " \n",
726
- " prediction_probs.append(cur_probs)\n",
727
- " prediction_classes.append(cur_predict)\n",
728
- " \n",
729
- " idx += 1\n",
730
- " \n",
731
- " return prediction_classes, prediction_probs, probs"
732
- ]
733
- },
734
- {
735
- "cell_type": "code",
736
- "execution_count": 148,
737
- "id": "55d10e54",
738
- "metadata": {
739
- "cellId": "ucqqhln4ocv503bn1tnrl"
740
- },
741
- "outputs": [],
742
- "source": [
743
- "#!g1.1\n",
744
- "title = \"strategic behaviour and indicative price diffusion in paris stock exchange auctions\"\n",
745
- "summary = \"we report statistical regularities of the opening and closing auctions of french equities, focusing on the diffusive properties of the indicative auction price. two mechanisms are at play as the auction end time nears: the typical price change magnitude decreases, favoring underdiffusion, while the rate of these events increases, potentially leading to overdiffusion. a third mechanism, caused by the strategic behavior of traders, is needed to produce nearly diffusive prices: waiting to submit buy orders until sell orders have decreased the indicative price and vice-versa.\"\n",
746
- "\n",
747
- "prediction_classes, prediction_probs, probs = predict_label(title, summary, tokenizer, model, inv_map)"
748
- ]
749
- },
750
- {
751
- "cell_type": "code",
752
- "execution_count": null,
753
- "id": "6beee65e",
754
- "metadata": {
755
- "cellId": "g78808bpr6o71yop72329p"
756
- },
757
- "outputs": [],
758
- "source": [
759
- "#!g1.1\n",
760
- "prediction_classes, prediction_probs, probs = predict_label(title, summary, tokenizer, model, inv_map)\n",
761
- " \n",
762
- "data = pd.DataFrame({'Categories' : tag, 'Probs' : probs})\n",
763
- "data = data.sort_values(by='Probs', ascending=False)"
764
- ]
765
- },
766
- {
767
- "cell_type": "code",
768
- "execution_count": null,
769
- "id": "19a82d5c",
770
- "metadata": {
771
- "cellId": "aclb6f96707kgmg5h42ctp"
772
- },
773
- "outputs": [],
774
- "source": [
775
- "#!g1.1\n",
776
- "data"
777
- ]
778
- },
779
- {
780
- "cell_type": "code",
781
- "execution_count": null,
782
- "id": "dffcbc7c",
783
- "metadata": {
784
- "cellId": "cxc30s516nw6j01mqya0q"
785
- },
786
- "outputs": [],
787
- "source": [
788
- "#!g1.1\n",
789
- "зд"
790
- ]
791
- },
792
- {
793
- "cell_type": "code",
794
- "execution_count": 140,
795
- "id": "aec20ffa",
796
- "metadata": {
797
- "cellId": "q0bj4c9toe6hr4gozk03y"
798
- },
799
- "outputs": [
800
- {
801
- "data": {
802
- "text/plain": [
803
- "<AxesSubplot:>"
804
- ]
805
- },
806
- "execution_count": 140,
807
- "metadata": {},
808
- "output_type": "execute_result"
809
- },
810
- {
811
- "data": {
812
- "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAASWUlEQVR4nO3dfbRldV3H8fdHhieXiOVMCQw5pEM1yxDtSg9mkk8LSJlclTBLM1wu6QmtfFiLluYDZiVmrlTUxkKtVCTTnHR0TBzSUmwuAiMzNDlNGoMWI7pIfADBb3/sfeF45z6cC/ve6/35fq11F3v/9u/u/WXffT7nd377nDOpKi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pqOSvddNx8Hntq3nQj8UN/3u0q6f9jk0H75AXTTBjckeWSS7+vbD6MbcSzGeb4YeFndNXc/5WjumsM/Z6T9q8BRi1DHgvSj623AG4G3APTzwEdX1Va66auHTvudrwL7k/xi3//wdO+meSDdDeg30438H76AUi4D7j31JJDuRuOr6aalLhp5kvpC339jP09+f7ppjR3T9reY1+1Ca112/b2b9SNNJ9M9Dkavw/vS3du7uZ/PP32k/+DX64oM9P4Z+MnA49K9bXEX8Md0Af6P/U2cnXQjytcvUVlH5jvfEvgn/UjuLOB1Sa4B/onu2fkNwL2SfIbujvg5NfxNxbFqHNn29pH2j/RtTwCu7WvfBrygqv4HeBDwz339VwGTdKPSQVV3U/u1M2y6EPjjJFfxnSOw7XQ3QUdvii6XtwPfBj7crx8FvD/JTuBfgOfO8Du/Cjyn7/MJutHpqcA1/f/rWcCfj1vAyOPkl5N8lu4ewrer6hWz/MpOunN4BfDyGcJz0a7bu1Hrd4P70E397e7/Zhvo7kVsBj6UZHt1b9a4Cvh34B3Av478/p39hirIj/5LiyDdO1eOrqo/WO5apiT5GbrpqydX1afn67+cVlKt300MdGlgSd5L9yrmMdW9lU1aEga6JDViRc6hS5IOZqBLUiMMdElqhIEuSY0w0CWpEf8PFO75xjPj3HgAAAAASUVORK5CYII=\n",
813
- "text/plain": [
814
- "<Figure size 432x288 with 1 Axes>"
815
- ]
816
- },
817
- "metadata": {
818
- "needs_background": "light"
819
- },
820
- "output_type": "display_data"
821
- }
822
- ],
823
- "source": [
824
- "#!g1.1\n",
825
- "import seaborn as sns\n",
826
- "\n",
827
- "tag = ['CS', 'Econ', 'EESS', \n",
828
- " 'Math', 'Physics', 'Q-bio', 'Q-fin', 'Stat']\n",
829
- "\n",
830
- "sns.barplot(x=tag, y=probs)"
831
- ]
832
- },
833
- {
834
- "cell_type": "code",
835
- "execution_count": 149,
836
- "id": "d28282e7",
837
- "metadata": {
838
- "cellId": "nr2s8dbt2tv474bv8e43"
839
- },
840
- "outputs": [
841
- {
842
- "data": {
843
- "text/plain": [
844
- "'┈┏╮┈┈┈╭┓┈┈╭┳━╮┈\\u2003\\n┈┃┗━━━┛┃┈┈╰┻╮┃┈\\u2003\\n┈┃╰╯┈╰╯┣━━━╮┃┃┈\\u2003\\n┈┃┈┈▲┈┈┃┈╭━┣╯┃┈\\u2003\\n┈╰┳╰━╯┳╯╭┛┈┣━╯┈\\u2003\\n┈┈╰╯┈╰╯┈╰━━╯┈┈┈'"
845
- ]
846
- },
847
- "execution_count": 149,
848
- "metadata": {},
849
- "output_type": "execute_result"
850
- }
851
- ],
852
- "source": [
853
- "#!g1.1\n"
854
- ]
855
- },
856
- {
857
- "cell_type": "code",
858
- "execution_count": 145,
859
- "id": "aae99fb0",
860
- "metadata": {
861
- "cellId": "xi82ygn14o9peav0j49tk"
862
- },
863
- "outputs": [
864
- {
865
- "ename": "AttributeError",
866
- "evalue": "module 'matplotlib.pyplot' has no attribute 'pyplot'",
867
- "output_type": "error",
868
- "traceback": [
869
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
870
- "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
871
- "\u001b[0;32m<ipython-input-1-eae06c26c813>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0max\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhist\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtag\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mprobs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbins\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m20\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 6\u001b[0;31m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpyplot\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfig\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 7\u001b[0m \u001b[0;31m#\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
872
- "\u001b[0;31mAttributeError\u001b[0m: module 'matplotlib.pyplot' has no attribute 'pyplot'"
873
- ]
874
- },
875
- {
876
- "name": "stderr",
877
- "output_type": "stream",
878
- "text": [
879
- "/kernel/lib/python3.8/site-packages/numpy/core/_asarray.py:83: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray\n",
880
- " return array(a, dtype, copy=False, order=order)\n"
881
- ]
882
- },
883
- {
884
- "ename": "ValueError",
885
- "evalue": "setting an array element with a sequence.",
886
- "output_type": "error",
887
- "traceback": [
888
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
889
- "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
890
- "\u001b[0;31mTypeError\u001b[0m: only size-1 arrays can be converted to Python scalars",
891
- "\nThe above exception was the direct cause of the following exception:\n",
892
- "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
893
- "\u001b[0;32m/kernel/lib/python3.8/site-packages/IPython/core/formatters.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, obj)\u001b[0m\n\u001b[1;32m 339\u001b[0m \u001b[0;32mpass\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 340\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 341\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mprinter\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mobj\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 342\u001b[0m \u001b[0;31m# Finally look for special method names\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 343\u001b[0m \u001b[0mmethod\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mget_real_method\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mobj\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mprint_method\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
894
- "\u001b[0;32m/kernel/lib/python3.8/site-packages/IPython/core/pylabtools.py\u001b[0m in \u001b[0;36m<lambda>\u001b[0;34m(fig)\u001b[0m\n\u001b[1;32m 246\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 247\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;34m'png'\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mformats\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 248\u001b[0;31m \u001b[0mpng_formatter\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfor_type\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mFigure\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;32mlambda\u001b[0m \u001b[0mfig\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mprint_figure\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfig\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'png'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 249\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;34m'retina'\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mformats\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0;34m'png2x'\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mformats\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 250\u001b[0m \u001b[0mpng_formatter\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfor_type\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mFigure\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;32mlambda\u001b[0m \u001b[0mfig\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mretina_figure\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfig\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
895
- "\u001b[0;32m/kernel/lib/python3.8/site-packages/IPython/core/pylabtools.py\u001b[0m in \u001b[0;36mprint_figure\u001b[0;34m(fig, fmt, bbox_inches, **kwargs)\u001b[0m\n\u001b[1;32m 130\u001b[0m \u001b[0mFigureCanvasBase\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfig\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 131\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 132\u001b[0;31m \u001b[0mfig\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcanvas\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mprint_figure\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbytes_io\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkw\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 133\u001b[0m \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mbytes_io\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgetvalue\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 134\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mfmt\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m'svg'\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
896
- "\u001b[0;32m/kernel/lib/python3.8/site-packages/matplotlib/backend_bases.py\u001b[0m in \u001b[0;36mprint_figure\u001b[0;34m(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)\u001b[0m\n\u001b[1;32m 2191\u001b[0m else suppress())\n\u001b[1;32m 2192\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mctx\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2193\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfigure\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdraw\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrenderer\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2194\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2195\u001b[0m bbox_inches = self.figure.get_tightbbox(\n",
897
- "\u001b[0;32m/kernel/lib/python3.8/site-packages/matplotlib/artist.py\u001b[0m in \u001b[0;36mdraw_wrapper\u001b[0;34m(artist, renderer, *args, **kwargs)\u001b[0m\n\u001b[1;32m 39\u001b[0m \u001b[0mrenderer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstart_filter\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 40\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 41\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mdraw\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0martist\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrenderer\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 42\u001b[0m \u001b[0;32mfinally\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 43\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0martist\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_agg_filter\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
898
- "\u001b[0;32m/kernel/lib/python3.8/site-packages/matplotlib/figure.py\u001b[0m in \u001b[0;36mdraw\u001b[0;34m(self, renderer)\u001b[0m\n\u001b[1;32m 1861\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1862\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpatch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdraw\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrenderer\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1863\u001b[0;31m mimage._draw_list_compositing_images(\n\u001b[0m\u001b[1;32m 1864\u001b[0m renderer, self, artists, self.suppressComposite)\n\u001b[1;32m 1865\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
899
- "\u001b[0;32m/kernel/lib/python3.8/site-packages/matplotlib/image.py\u001b[0m in \u001b[0;36m_draw_list_compositing_images\u001b[0;34m(renderer, parent, artists, suppress_composite)\u001b[0m\n\u001b[1;32m 129\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mnot_composite\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mhas_images\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 130\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0ma\u001b[0m \u001b[0;32min\u001b[0m \u001b[0martists\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 131\u001b[0;31m \u001b[0ma\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdraw\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrenderer\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 132\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 133\u001b[0m \u001b[0;31m# Composite any adjacent images together\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
900
- "\u001b[0;32m/kernel/lib/python3.8/site-packages/matplotlib/artist.py\u001b[0m in \u001b[0;36mdraw_wrapper\u001b[0;34m(artist, renderer, *args, **kwargs)\u001b[0m\n\u001b[1;32m 39\u001b[0m \u001b[0mrenderer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstart_filter\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 40\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 41\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mdraw\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0martist\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrenderer\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 42\u001b[0m \u001b[0;32mfinally\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 43\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0martist\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_agg_filter\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
901
- "\u001b[0;32m/kernel/lib/python3.8/site-packages/matplotlib/cbook/deprecation.py\u001b[0m in \u001b[0;36mwrapper\u001b[0;34m(*inner_args, **inner_kwargs)\u001b[0m\n\u001b[1;32m 409\u001b[0m \u001b[0;32melse\u001b[0m \u001b[0mdeprecation_addendum\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 410\u001b[0m **kwargs)\n\u001b[0;32m--> 411\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0minner_args\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0minner_kwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 412\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 413\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mwrapper\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
902
- "\u001b[0;32m/kernel/lib/python3.8/site-packages/matplotlib/axes/_base.py\u001b[0m in \u001b[0;36mdraw\u001b[0;34m(self, renderer, inframe)\u001b[0m\n\u001b[1;32m 2745\u001b[0m \u001b[0mrenderer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstop_rasterizing\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2746\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2747\u001b[0;31m \u001b[0mmimage\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_draw_list_compositing_images\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrenderer\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0martists\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2748\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2749\u001b[0m \u001b[0mrenderer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mclose_group\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'axes'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
903
- "\u001b[0;32m/kernel/lib/python3.8/site-packages/matplotlib/image.py\u001b[0m in \u001b[0;36m_draw_list_compositing_images\u001b[0;34m(renderer, parent, artists, suppress_composite)\u001b[0m\n\u001b[1;32m 129\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mnot_composite\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mhas_images\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 130\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0ma\u001b[0m \u001b[0;32min\u001b[0m \u001b[0martists\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 131\u001b[0;31m \u001b[0ma\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdraw\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrenderer\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 132\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 133\u001b[0m \u001b[0;31m# Composite any adjacent images together\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
904
- "\u001b[0;32m/kernel/lib/python3.8/site-packages/matplotlib/artist.py\u001b[0m in \u001b[0;36mdraw_wrapper\u001b[0;34m(artist, renderer, *args, **kwargs)\u001b[0m\n\u001b[1;32m 39\u001b[0m \u001b[0mrenderer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstart_filter\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 40\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 41\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mdraw\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0martist\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrenderer\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 42\u001b[0m \u001b[0;32mfinally\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 43\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0martist\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_agg_filter\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
905
- "\u001b[0;32m/kernel/lib/python3.8/site-packages/matplotlib/patches.py\u001b[0m in \u001b[0;36mdraw\u001b[0;34m(self, renderer)\u001b[0m\n\u001b[1;32m 582\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_bind_draw_path_function\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrenderer\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mdraw_path\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 583\u001b[0m \u001b[0mpath\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_path\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 584\u001b[0;31m \u001b[0mtransform\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_transform\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 585\u001b[0m \u001b[0mtpath\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtransform\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtransform_path_non_affine\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 586\u001b[0m \u001b[0maffine\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtransform\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_affine\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
906
- "\u001b[0;32m/kernel/lib/python3.8/site-packages/matplotlib/patches.py\u001b[0m in \u001b[0;36mget_transform\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 258\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mget_transform\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 259\u001b[0m \u001b[0;34m\"\"\"Return the `~.transforms.Transform` applied to the `Patch`.\"\"\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 260\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_patch_transform\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0martist\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mArtist\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_transform\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 261\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 262\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mget_data_transform\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
907
- "\u001b[0;32m/kernel/lib/python3.8/site-packages/matplotlib/patches.py\u001b[0m in \u001b[0;36mget_patch_transform\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 790\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 791\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mget_patch_transform\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 792\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_update_patch_transform\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 793\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_rect_transform\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 794\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
908
- "\u001b[0;32m/kernel/lib/python3.8/site-packages/matplotlib/patches.py\u001b[0m in \u001b[0;36m_update_patch_transform\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 769\u001b[0m \"\"\"\n\u001b[1;32m 770\u001b[0m \u001b[0mx0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mx1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my1\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_convert_units\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 771\u001b[0;31m \u001b[0mbbox\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtransforms\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mBbox\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfrom_extents\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mx1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 772\u001b[0m \u001b[0mrot_trans\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtransforms\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mAffine2D\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 773\u001b[0m \u001b[0mrot_trans\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrotate_deg_around\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mangle\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
909
- "\u001b[0;32m/kernel/lib/python3.8/site-packages/matplotlib/transforms.py\u001b[0m in \u001b[0;36mfrom_extents\u001b[0;34m(*args)\u001b[0m\n\u001b[1;32m 820\u001b[0m \u001b[0mThe\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0my\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0maxis\u001b[0m \u001b[0mincreases\u001b[0m \u001b[0mupwards\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 821\u001b[0m \"\"\"\n\u001b[0;32m--> 822\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mBbox\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreshape\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 823\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 824\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__format__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfmt\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
910
- "\u001b[0;32m/kernel/lib/python3.8/site-packages/matplotlib/transforms.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, points, **kwargs)\u001b[0m\n\u001b[1;32m 772\u001b[0m \"\"\"\n\u001b[1;32m 773\u001b[0m \u001b[0mBboxBase\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__init__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 774\u001b[0;31m \u001b[0mpoints\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0masarray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpoints\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfloat\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 775\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mpoints\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 776\u001b[0m raise ValueError('Bbox points must be of the form '\n",
911
- "\u001b[0;32m/kernel/lib/python3.8/site-packages/numpy/core/_asarray.py\u001b[0m in \u001b[0;36masarray\u001b[0;34m(a, dtype, order)\u001b[0m\n\u001b[1;32m 81\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 82\u001b[0m \"\"\"\n\u001b[0;32m---> 83\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcopy\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0morder\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0morder\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 84\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 85\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
912
- "\u001b[0;31mValueError\u001b[0m: setting an array element with a sequence."
913
- ]
914
- },
915
- {
916
- "data": {
917
- "text/plain": [
918
- "<Figure size 432x288 with 1 Axes>"
919
- ]
920
- },
921
- "metadata": {
922
- "needs_background": "light"
923
- },
924
- "output_type": "display_data"
925
- }
926
- ],
927
- "source": [
928
- "#!g1.1\n",
929
- "import matplotlib.pyplot as plt\n",
930
- "\n",
931
- "fig, ax = plt.subplots()\n",
932
- "ax.hist(x=tag, y=probs, bins=20)\n",
933
- "\n",
934
- "plt.pyplot(fig)"
935
- ]
936
- },
937
- {
938
- "cell_type": "code",
939
- "execution_count": 144,
940
- "id": "38d8c3b7",
941
- "metadata": {
942
- "cellId": "kehpd4xdcpjpjfptvfspg"
943
- },
944
- "outputs": [
945
- {
946
- "name": "stderr",
947
- "output_type": "stream",
948
- "text": [
949
- "Configuration saved in my_beautiful_model/config.json\n",
950
- "Model weights saved in my_beautiful_model/pytorch_model.bin\n",
951
- "/kernel/lib/python3.8/site-packages/ml_kernel/kernel.py:872: UserWarning: The following variables cannot be serialized: trainer\n",
952
- " warnings.warn(message)\n"
953
- ]
954
- }
955
- ],
956
- "source": [
957
- "#!g1.1\n",
958
- "model.save_pretrained(\"my_beautiful_model\")"
959
- ]
960
- }
961
- ],
962
- "metadata": {
963
- "kernelspec": {
964
- "display_name": "Yandex DataSphere Kernel",
965
- "language": "python",
966
- "name": "python3"
967
- },
968
- "language_info": {
969
- "codemirror_mode": {
970
- "name": "ipython",
971
- "version": 3
972
- },
973
- "file_extension": ".py",
974
- "mimetype": "text/x-python",
975
- "name": "python",
976
- "nbconvert_exporter": "python",
977
- "pygments_lexer": "ipython3",
978
- "version": "3.7.7"
979
- },
980
- "notebookId": "ee1ba0a4-4ed3-4508-aaee-3fe3cf7b2f0c",
981
- "notebookPath": "Untitled (1).ipynb"
982
- },
983
- "nbformat": 4,
984
- "nbformat_minor": 5
985
- }