added tqdm
This commit is contained in:
parent
e8f7d1ef96
commit
ef687f9e92
35
1_nbow.ipynb
35
1_nbow.ipynb
@ -8,18 +8,16 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import functools\n",
|
||||
"import sys\n",
|
||||
"\n",
|
||||
"import datasets\n",
|
||||
"\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"\n",
|
||||
"import numpy as np\n",
|
||||
"\n",
|
||||
"import torch\n",
|
||||
"import torch.nn as nn\n",
|
||||
"import torch.optim as optim\n",
|
||||
"\n",
|
||||
"import torchtext"
|
||||
"import torchtext\n",
|
||||
"import tqdm"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -31,7 +29,7 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"<torch._C.Generator at 0x7fd4fab4c930>"
|
||||
"<torch._C.Generator at 0x7f851a9849b0>"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
@ -1910,7 +1908,7 @@
|
||||
" epoch_losses = []\n",
|
||||
" epoch_accs = []\n",
|
||||
"\n",
|
||||
" for batch in dataloader:\n",
|
||||
" for batch in tqdm.tqdm(dataloader, desc='training...', file=sys.stdout):\n",
|
||||
" ids = batch['ids'].to(device)\n",
|
||||
" label = batch['label'].to(device)\n",
|
||||
" prediction = model(ids)\n",
|
||||
@ -1939,7 +1937,7 @@
|
||||
" epoch_accs = []\n",
|
||||
"\n",
|
||||
" with torch.no_grad():\n",
|
||||
" for batch in dataloader:\n",
|
||||
" for batch in tqdm.tqdm(dataloader, desc='evaluating...', file=sys.stdout):\n",
|
||||
" ids = batch['ids'].to(device)\n",
|
||||
" label = batch['label'].to(device)\n",
|
||||
" prediction = model(ids)\n",
|
||||
@ -1976,33 +1974,53 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"training...: 100%|██████████| 37/37 [00:02<00:00, 14.13it/s]\n",
|
||||
"evaluating...: 100%|██████████| 13/13 [00:00<00:00, 16.12it/s]\n",
|
||||
"epoch: 1\n",
|
||||
"train_loss: 0.684, train_acc: 0.604\n",
|
||||
"valid_loss: 0.671, valid_acc: 0.682\n",
|
||||
"training...: 100%|██████████| 37/37 [00:02<00:00, 15.06it/s]\n",
|
||||
"evaluating...: 100%|██████████| 13/13 [00:00<00:00, 16.24it/s]\n",
|
||||
"epoch: 2\n",
|
||||
"train_loss: 0.648, train_acc: 0.718\n",
|
||||
"valid_loss: 0.627, valid_acc: 0.729\n",
|
||||
"training...: 100%|██████████| 37/37 [00:02<00:00, 14.65it/s]\n",
|
||||
"evaluating...: 100%|██████████| 13/13 [00:00<00:00, 15.88it/s]\n",
|
||||
"epoch: 3\n",
|
||||
"train_loss: 0.588, train_acc: 0.764\n",
|
||||
"valid_loss: 0.567, valid_acc: 0.769\n",
|
||||
"training...: 100%|██████████| 37/37 [00:02<00:00, 14.81it/s]\n",
|
||||
"evaluating...: 100%|██████████| 13/13 [00:00<00:00, 15.66it/s]\n",
|
||||
"epoch: 4\n",
|
||||
"train_loss: 0.516, train_acc: 0.807\n",
|
||||
"valid_loss: 0.504, valid_acc: 0.803\n",
|
||||
"training...: 100%|██████████| 37/37 [00:02<00:00, 14.80it/s]\n",
|
||||
"evaluating...: 100%|██████████| 13/13 [00:00<00:00, 15.93it/s]\n",
|
||||
"epoch: 5\n",
|
||||
"train_loss: 0.446, train_acc: 0.847\n",
|
||||
"valid_loss: 0.450, valid_acc: 0.833\n",
|
||||
"training...: 100%|██████████| 37/37 [00:02<00:00, 14.83it/s]\n",
|
||||
"evaluating...: 100%|██████████| 13/13 [00:00<00:00, 16.03it/s]\n",
|
||||
"epoch: 6\n",
|
||||
"train_loss: 0.388, train_acc: 0.870\n",
|
||||
"valid_loss: 0.411, valid_acc: 0.844\n",
|
||||
"training...: 100%|██████████| 37/37 [00:02<00:00, 15.40it/s]\n",
|
||||
"evaluating...: 100%|██████████| 13/13 [00:00<00:00, 16.37it/s]\n",
|
||||
"epoch: 7\n",
|
||||
"train_loss: 0.343, train_acc: 0.886\n",
|
||||
"valid_loss: 0.384, valid_acc: 0.852\n",
|
||||
"training...: 100%|██████████| 37/37 [00:02<00:00, 15.13it/s]\n",
|
||||
"evaluating...: 100%|██████████| 13/13 [00:00<00:00, 16.03it/s]\n",
|
||||
"epoch: 8\n",
|
||||
"train_loss: 0.308, train_acc: 0.899\n",
|
||||
"valid_loss: 0.364, valid_acc: 0.857\n",
|
||||
"training...: 100%|██████████| 37/37 [00:02<00:00, 14.99it/s]\n",
|
||||
"evaluating...: 100%|██████████| 13/13 [00:00<00:00, 16.12it/s]\n",
|
||||
"epoch: 9\n",
|
||||
"train_loss: 0.280, train_acc: 0.909\n",
|
||||
"valid_loss: 0.349, valid_acc: 0.862\n",
|
||||
"training...: 100%|██████████| 37/37 [00:02<00:00, 14.62it/s]\n",
|
||||
"evaluating...: 100%|██████████| 13/13 [00:00<00:00, 16.37it/s]\n",
|
||||
"epoch: 10\n",
|
||||
"train_loss: 0.257, train_acc: 0.917\n",
|
||||
"valid_loss: 0.336, valid_acc: 0.867\n"
|
||||
@ -2110,6 +2128,7 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"evaluating...: 100%|██████████| 49/49 [00:03<00:00, 15.38it/s]\n",
|
||||
"test_loss: 0.353, test_acc: 0.857\n"
|
||||
]
|
||||
}
|
||||
|
123
2_lstm.ipynb
123
2_lstm.ipynb
File diff suppressed because one or more lines are too long
67
3_cnn.ipynb
67
3_cnn.ipynb
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user