You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

fastnlp_tutorial_6.ipynb 72 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "id": "fdd7ff16",
  6. "metadata": {},
  7. "source": [
  8. "# T6. fastNLP 与 paddle 或 jittor 的结合\n",
  9. "\n",
  10. "  1   fastNLP 结合 paddle 训练模型\n",
  11. " \n",
  12. "    1.1   关于 paddle 的简单介绍\n",
  13. "\n",
  14. "    1.2   使用 paddle 搭建并训练模型\n",
  15. "\n",
  16. "  2   fastNLP 结合 jittor 训练模型\n",
  17. "\n",
  18. "    2.1   关于 jittor 的简单介绍\n",
  19. "\n",
  20. "    2.2   使用 jittor 搭建并训练模型\n",
  21. "\n",
  22. "<!-- &emsp; 3 &ensp; fastNLP 实现 paddle 与 pytorch 互转 -->"
  23. ]
  24. },
  25. {
  26. "cell_type": "code",
  27. "execution_count": 1,
  28. "id": "08752c5a",
  29. "metadata": {},
  30. "outputs": [
  31. {
  32. "name": "stderr",
  33. "output_type": "stream",
  34. "text": [
  35. "Reusing dataset glue (/remote-home/xrliu/.cache/huggingface/datasets/glue/sst2/1.0.0/dacbe3125aa31d7f70367a07a8a9e72a5a0bfeb5fc42e75c9db75b96da6053ad)\n"
  36. ]
  37. },
  38. {
  39. "data": {
  40. "application/vnd.jupyter.widget-view+json": {
  41. "model_id": "6b13d42c39ba455eb370bf2caaa3a264",
  42. "version_major": 2,
  43. "version_minor": 0
  44. },
  45. "text/plain": [
  46. " 0%| | 0/3 [00:00<?, ?it/s]"
  47. ]
  48. },
  49. "metadata": {},
  50. "output_type": "display_data"
  51. }
  52. ],
  53. "source": [
  54. "from datasets import load_dataset\n",
  55. "\n",
  56. "sst2data = load_dataset('glue', 'sst2')"
  57. ]
  58. },
  59. {
  60. "cell_type": "code",
  61. "execution_count": 2,
  62. "id": "7e8cc210",
  63. "metadata": {},
  64. "outputs": [
  65. {
  66. "name": "stderr",
  67. "output_type": "stream",
  68. "text": [
  69. "\u001b[38;5;2m[i 0604 21:01:38.510813 72 log.cc:351] Load log_sync: 1\u001b[m\n"
  70. ]
  71. },
  72. {
  73. "data": {
  74. "text/html": [
  75. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  76. "</pre>\n"
  77. ],
  78. "text/plain": [
  79. "\n"
  80. ]
  81. },
  82. "metadata": {},
  83. "output_type": "display_data"
  84. },
  85. {
  86. "data": {
  87. "application/vnd.jupyter.widget-view+json": {
  88. "model_id": "",
  89. "version_major": 2,
  90. "version_minor": 0
  91. },
  92. "text/plain": [
  93. "Processing: 0%| | 0/6000 [00:00<?, ?it/s]"
  94. ]
  95. },
  96. "metadata": {},
  97. "output_type": "display_data"
  98. },
  99. {
  100. "name": "stdout",
  101. "output_type": "stream",
  102. "text": [
  103. "<class 'fastNLP.core.dataset.dataset.DataSet'> True\n"
  104. ]
  105. }
  106. ],
  107. "source": [
  108. "import sys\n",
  109. "sys.path.append('..')\n",
  110. "\n",
  111. "from fastNLP import DataSet\n",
  112. "\n",
  113. "dataset = DataSet.from_pandas(sst2data['train'].to_pandas())[:6000]\n",
  114. "\n",
  115. "dataset.apply_more(lambda ins:{'words': ins['sentence'].lower().split(), 'target': ins['label']}, \n",
  116. " progress_bar=\"tqdm\")\n",
  117. "dataset.delete_field('sentence')\n",
  118. "dataset.delete_field('label')\n",
  119. "dataset.delete_field('idx')\n",
  120. "\n",
  121. "from fastNLP import Vocabulary\n",
  122. "\n",
  123. "vocab = Vocabulary()\n",
  124. "vocab.from_dataset(dataset, field_name='words')\n",
  125. "vocab.index_dataset(dataset, field_name='words')\n",
  126. "\n",
  127. "train_dataset, evaluate_dataset = dataset.split(ratio=0.85)\n",
  128. "print(type(train_dataset), isinstance(train_dataset, DataSet))\n",
  129. "\n",
  130. "from fastNLP.io import DataBundle\n",
  131. "\n",
  132. "data_bundle = DataBundle(datasets={'train': train_dataset, 'dev': evaluate_dataset})"
  133. ]
  134. },
  135. {
  136. "cell_type": "markdown",
  137. "id": "57a3272f",
  138. "metadata": {},
  139. "source": [
  140. "## 1. fastNLP 结合 paddle 训练模型\n",
  141. "\n"
  142. ]
  143. },
  144. {
  145. "cell_type": "code",
  146. "execution_count": 3,
  147. "id": "e31b3198",
  148. "metadata": {},
  149. "outputs": [],
  150. "source": [
  151. "import paddle\n",
  152. "import paddle.nn as nn\n",
  153. "import paddle.nn.functional as F\n",
  154. "\n",
  155. "\n",
  156. "class ClsByPaddle(nn.Layer):\n",
  157. " def __init__(self, vocab_size, embedding_dim, output_dim, hidden_dim=64, dropout=0.5):\n",
  158. " nn.Layer.__init__(self)\n",
  159. " self.hidden_dim = hidden_dim\n",
  160. "\n",
  161. " self.embedding = nn.Embedding(num_embeddings=vocab_size, embedding_dim=embedding_dim)\n",
  162. " \n",
  163. " self.conv1 = nn.Sequential(nn.Conv1D(embedding_dim, 30, 1, padding=0), nn.ReLU())\n",
  164. " self.conv2 = nn.Sequential(nn.Conv1D(embedding_dim, 40, 3, padding=1), nn.ReLU())\n",
  165. " self.conv3 = nn.Sequential(nn.Conv1D(embedding_dim, 50, 5, padding=2), nn.ReLU())\n",
  166. "\n",
  167. " self.mlp = nn.Sequential(('dropout', nn.Dropout(p=dropout)),\n",
  168. " ('linear_1', nn.Linear(120, hidden_dim)),\n",
  169. " ('activate', nn.ReLU()),\n",
  170. " ('linear_2', nn.Linear(hidden_dim, output_dim)))\n",
  171. " \n",
  172. " self.loss_fn = nn.MSELoss()\n",
  173. "\n",
  174. " def forward(self, words):\n",
  175. " output = self.embedding(words).transpose([0, 2, 1])\n",
  176. " conv1, conv2, conv3 = self.conv1(output), self.conv2(output), self.conv3(output)\n",
  177. "\n",
  178. " pool1 = F.max_pool1d(conv1, conv1.shape[-1]).squeeze(2)\n",
  179. " pool2 = F.max_pool1d(conv2, conv2.shape[-1]).squeeze(2)\n",
  180. " pool3 = F.max_pool1d(conv3, conv3.shape[-1]).squeeze(2)\n",
  181. "\n",
  182. " pool = paddle.concat([pool1, pool2, pool3], axis=1)\n",
  183. " output = self.mlp(pool)\n",
  184. " return output\n",
  185. " \n",
  186. " def train_step(self, words, target):\n",
  187. " pred = self(words)\n",
  188. " target = paddle.stack((1 - target, target), axis=1).cast(pred.dtype)\n",
  189. " return {'loss': self.loss_fn(pred, target)}\n",
  190. "\n",
  191. " def evaluate_step(self, words, target):\n",
  192. " pred = self(words)\n",
  193. " pred = paddle.argmax(pred, axis=-1)\n",
  194. " return {'pred': pred, 'target': target}"
  195. ]
  196. },
  197. {
  198. "cell_type": "code",
  199. "execution_count": 4,
  200. "id": "c63b030f",
  201. "metadata": {},
  202. "outputs": [
  203. {
  204. "name": "stderr",
  205. "output_type": "stream",
  206. "text": [
  207. "W0604 21:02:25.453869 19014 gpu_context.cc:278] Please NOTE: device: 0, GPU Compute Capability: 6.1, Driver API Version: 11.1, Runtime API Version: 10.2\n",
  208. "W0604 21:02:26.061690 19014 gpu_context.cc:306] device: 0, cuDNN Version: 7.6.\n"
  209. ]
  210. },
  211. {
  212. "data": {
  213. "text/plain": [
  214. "ClsByPaddle(\n",
  215. " (embedding): Embedding(8458, 100, sparse=False)\n",
  216. " (conv1): Sequential(\n",
  217. " (0): Conv1D(100, 30, kernel_size=[1], data_format=NCL)\n",
  218. " (1): ReLU()\n",
  219. " )\n",
  220. " (conv2): Sequential(\n",
  221. " (0): Conv1D(100, 40, kernel_size=[3], padding=1, data_format=NCL)\n",
  222. " (1): ReLU()\n",
  223. " )\n",
  224. " (conv3): Sequential(\n",
  225. " (0): Conv1D(100, 50, kernel_size=[5], padding=2, data_format=NCL)\n",
  226. " (1): ReLU()\n",
  227. " )\n",
  228. " (mlp): Sequential(\n",
  229. " (dropout): Dropout(p=0.5, axis=None, mode=upscale_in_train)\n",
  230. " (linear_1): Linear(in_features=120, out_features=64, dtype=float32)\n",
  231. " (activate): ReLU()\n",
  232. " (linear_2): Linear(in_features=64, out_features=2, dtype=float32)\n",
  233. " )\n",
  234. " (loss_fn): MSELoss()\n",
  235. ")"
  236. ]
  237. },
  238. "execution_count": 4,
  239. "metadata": {},
  240. "output_type": "execute_result"
  241. }
  242. ],
  243. "source": [
  244. "model = ClsByPaddle(vocab_size=len(vocab), embedding_dim=100, output_dim=2)\n",
  245. "\n",
  246. "model"
  247. ]
  248. },
  249. {
  250. "cell_type": "code",
  251. "execution_count": 5,
  252. "id": "2997c0aa",
  253. "metadata": {},
  254. "outputs": [],
  255. "source": [
  256. "from paddle.optimizer import AdamW\n",
  257. "\n",
  258. "optimizers = AdamW(parameters=model.parameters(), learning_rate=5e-4)"
  259. ]
  260. },
  261. {
  262. "cell_type": "code",
  263. "execution_count": 6,
  264. "id": "ead35fb8",
  265. "metadata": {},
  266. "outputs": [],
  267. "source": [
  268. "from fastNLP import prepare_paddle_dataloader\n",
  269. "\n",
  270. "train_dataloader = prepare_paddle_dataloader(train_dataset, batch_size=16, shuffle=True)\n",
  271. "evaluate_dataloader = prepare_paddle_dataloader(evaluate_dataset, batch_size=16)\n",
  272. "\n",
  273. "# dl_bundle = prepare_paddle_dataloader(data_bundle, batch_size=16, shuffle=True)"
  274. ]
  275. },
  276. {
  277. "cell_type": "code",
  278. "execution_count": 7,
  279. "id": "25e8da83",
  280. "metadata": {},
  281. "outputs": [],
  282. "source": [
  283. "from fastNLP import Trainer, Accuracy\n",
  284. "\n",
  285. "trainer = Trainer(\n",
  286. " model=model,\n",
  287. " driver='paddle',\n",
  288. " device='gpu', # 'cpu', 'gpu', 'gpu:x'\n",
  289. " n_epochs=10,\n",
  290. " optimizers=optimizers,\n",
  291. " train_dataloader=train_dataloader, # dl_bundle['train'],\n",
  292. " evaluate_dataloaders=evaluate_dataloader, # dl_bundle['dev'], \n",
  293. " metrics={'acc': Accuracy()}\n",
  294. ")"
  295. ]
  296. },
  297. {
  298. "cell_type": "code",
  299. "execution_count": 8,
  300. "id": "d63c5d74",
  301. "metadata": {},
  302. "outputs": [
  303. {
  304. "data": {
  305. "text/html": [
  306. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7fbfbf; text-decoration-color: #7fbfbf\">[21:03:08] </span><span style=\"color: #000080; text-decoration-color: #000080\">INFO </span> Running evaluator sanity check for <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span> batches. <a href=\"file://../fastNLP/core/controllers/trainer.py\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">trainer.py</span></a><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">:</span><a href=\"file://../fastNLP/core/controllers/trainer.py#596\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">596</span></a>\n",
  307. "</pre>\n"
  308. ],
  309. "text/plain": [
  310. "\u001b[2;36m[21:03:08]\u001b[0m\u001b[2;36m \u001b[0m\u001b[34mINFO \u001b[0m Running evaluator sanity check for \u001b[1;36m2\u001b[0m batches. \u001b]8;id=894986;file://../fastNLP/core/controllers/trainer.py\u001b\\\u001b[2mtrainer.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=567751;file://../fastNLP/core/controllers/trainer.py#596\u001b\\\u001b[2m596\u001b[0m\u001b]8;;\u001b\\\n"
  311. ]
  312. },
  313. "metadata": {},
  314. "output_type": "display_data"
  315. },
  316. {
  317. "data": {
  318. "application/vnd.jupyter.widget-view+json": {
  319. "model_id": "",
  320. "version_major": 2,
  321. "version_minor": 0
  322. },
  323. "text/plain": [
  324. "Output()"
  325. ]
  326. },
  327. "metadata": {},
  328. "output_type": "display_data"
  329. },
  330. {
  331. "data": {
  332. "text/html": [
  333. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">/remote-home/xrliu/anaconda3/envs/demo/lib/python3.7/site-packages/ipywidgets/widgets/widget_\n",
  334. "output.py:111: DeprecationWarning: Kernel._parent_header is deprecated in ipykernel 6. Use \n",
  335. ".get_parent()\n",
  336. " if ip and hasattr(ip, 'kernel') and hasattr(ip.kernel, '_parent_header'):\n",
  337. "</pre>\n"
  338. ],
  339. "text/plain": [
  340. "/remote-home/xrliu/anaconda3/envs/demo/lib/python3.7/site-packages/ipywidgets/widgets/widget_\n",
  341. "output.py:111: DeprecationWarning: Kernel._parent_header is deprecated in ipykernel 6. Use \n",
  342. ".get_parent()\n",
  343. " if ip and hasattr(ip, 'kernel') and hasattr(ip.kernel, '_parent_header'):\n"
  344. ]
  345. },
  346. "metadata": {},
  347. "output_type": "display_data"
  348. },
  349. {
  350. "data": {
  351. "text/html": [
  352. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">/remote-home/xrliu/anaconda3/envs/demo/lib/python3.7/site-packages/ipywidgets/widgets/widget_\n",
  353. "output.py:112: DeprecationWarning: Kernel._parent_header is deprecated in ipykernel 6. Use \n",
  354. ".get_parent()\n",
  355. " self.msg_id = ip.kernel._parent_header['header']['msg_id']\n",
  356. "</pre>\n"
  357. ],
  358. "text/plain": [
  359. "/remote-home/xrliu/anaconda3/envs/demo/lib/python3.7/site-packages/ipywidgets/widgets/widget_\n",
  360. "output.py:112: DeprecationWarning: Kernel._parent_header is deprecated in ipykernel 6. Use \n",
  361. ".get_parent()\n",
  362. " self.msg_id = ip.kernel._parent_header['header']['msg_id']\n"
  363. ]
  364. },
  365. "metadata": {},
  366. "output_type": "display_data"
  367. },
  368. {
  369. "data": {
  370. "text/html": [
  371. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">/remote-home/xrliu/anaconda3/envs/demo/lib/python3.7/site-packages/paddle/tensor/creation.py:\n",
  372. "125: DeprecationWarning: `np.object` is a deprecated alias for the builtin `object`. To \n",
  373. "silence this warning, use `object` by itself. Doing this will not modify any behavior and is \n",
  374. "safe. \n",
  375. "Deprecated in NumPy 1.20; for more details and guidance: \n",
  376. "https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
  377. " if data.dtype == np.object:\n",
  378. "</pre>\n"
  379. ],
  380. "text/plain": [
  381. "/remote-home/xrliu/anaconda3/envs/demo/lib/python3.7/site-packages/paddle/tensor/creation.py:\n",
  382. "125: DeprecationWarning: `np.object` is a deprecated alias for the builtin `object`. To \n",
  383. "silence this warning, use `object` by itself. Doing this will not modify any behavior and is \n",
  384. "safe. \n",
  385. "Deprecated in NumPy 1.20; for more details and guidance: \n",
  386. "https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
  387. " if data.dtype == np.object:\n"
  388. ]
  389. },
  390. "metadata": {},
  391. "output_type": "display_data"
  392. },
  393. {
  394. "data": {
  395. "text/html": [
  396. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
  397. ],
  398. "text/plain": []
  399. },
  400. "metadata": {},
  401. "output_type": "display_data"
  402. },
  403. {
  404. "data": {
  405. "application/vnd.jupyter.widget-view+json": {
  406. "model_id": "",
  407. "version_major": 2,
  408. "version_minor": 0
  409. },
  410. "text/plain": [
  411. "Output()"
  412. ]
  413. },
  414. "metadata": {},
  415. "output_type": "display_data"
  416. },
  417. {
  418. "data": {
  419. "text/html": [
  420. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  421. "</pre>\n"
  422. ],
  423. "text/plain": [
  424. "\n"
  425. ]
  426. },
  427. "metadata": {},
  428. "output_type": "display_data"
  429. },
  430. {
  431. "data": {
  432. "text/html": [
  433. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">----------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span> -----------------------------\n",
  434. "</pre>\n"
  435. ],
  436. "text/plain": [
  437. "----------------------------- Eval. results on Epoch:\u001b[1;36m1\u001b[0m, Batch:\u001b[1;36m0\u001b[0m -----------------------------\n"
  438. ]
  439. },
  440. "metadata": {},
  441. "output_type": "display_data"
  442. },
  443. {
  444. "data": {
  445. "text/html": [
  446. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  447. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.78125</span>,\n",
  448. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">160.0</span>,\n",
  449. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">125.0</span>\n",
  450. "<span style=\"font-weight: bold\">}</span>\n",
  451. "</pre>\n"
  452. ],
  453. "text/plain": [
  454. "\u001b[1m{\u001b[0m\n",
  455. " \u001b[1;34m\"acc#acc\"\u001b[0m: \u001b[1;36m0.78125\u001b[0m,\n",
  456. " \u001b[1;34m\"total#acc\"\u001b[0m: \u001b[1;36m160.0\u001b[0m,\n",
  457. " \u001b[1;34m\"correct#acc\"\u001b[0m: \u001b[1;36m125.0\u001b[0m\n",
  458. "\u001b[1m}\u001b[0m\n"
  459. ]
  460. },
  461. "metadata": {},
  462. "output_type": "display_data"
  463. },
  464. {
  465. "data": {
  466. "text/html": [
  467. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  468. "</pre>\n"
  469. ],
  470. "text/plain": [
  471. "\n"
  472. ]
  473. },
  474. "metadata": {},
  475. "output_type": "display_data"
  476. },
  477. {
  478. "data": {
  479. "text/html": [
  480. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">----------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span> -----------------------------\n",
  481. "</pre>\n"
  482. ],
  483. "text/plain": [
  484. "----------------------------- Eval. results on Epoch:\u001b[1;36m2\u001b[0m, Batch:\u001b[1;36m0\u001b[0m -----------------------------\n"
  485. ]
  486. },
  487. "metadata": {},
  488. "output_type": "display_data"
  489. },
  490. {
  491. "data": {
  492. "text/html": [
  493. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  494. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.7875</span>,\n",
  495. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">160.0</span>,\n",
  496. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">126.0</span>\n",
  497. "<span style=\"font-weight: bold\">}</span>\n",
  498. "</pre>\n"
  499. ],
  500. "text/plain": [
  501. "\u001b[1m{\u001b[0m\n",
  502. " \u001b[1;34m\"acc#acc\"\u001b[0m: \u001b[1;36m0.7875\u001b[0m,\n",
  503. " \u001b[1;34m\"total#acc\"\u001b[0m: \u001b[1;36m160.0\u001b[0m,\n",
  504. " \u001b[1;34m\"correct#acc\"\u001b[0m: \u001b[1;36m126.0\u001b[0m\n",
  505. "\u001b[1m}\u001b[0m\n"
  506. ]
  507. },
  508. "metadata": {},
  509. "output_type": "display_data"
  510. },
  511. {
  512. "data": {
  513. "text/html": [
  514. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  515. "</pre>\n"
  516. ],
  517. "text/plain": [
  518. "\n"
  519. ]
  520. },
  521. "metadata": {},
  522. "output_type": "display_data"
  523. },
  524. {
  525. "data": {
  526. "text/html": [
  527. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">----------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">3</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span> -----------------------------\n",
  528. "</pre>\n"
  529. ],
  530. "text/plain": [
  531. "----------------------------- Eval. results on Epoch:\u001b[1;36m3\u001b[0m, Batch:\u001b[1;36m0\u001b[0m -----------------------------\n"
  532. ]
  533. },
  534. "metadata": {},
  535. "output_type": "display_data"
  536. },
  537. {
  538. "data": {
  539. "text/html": [
  540. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  541. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.8</span>,\n",
  542. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">160.0</span>,\n",
  543. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">128.0</span>\n",
  544. "<span style=\"font-weight: bold\">}</span>\n",
  545. "</pre>\n"
  546. ],
  547. "text/plain": [
  548. "\u001b[1m{\u001b[0m\n",
  549. " \u001b[1;34m\"acc#acc\"\u001b[0m: \u001b[1;36m0.8\u001b[0m,\n",
  550. " \u001b[1;34m\"total#acc\"\u001b[0m: \u001b[1;36m160.0\u001b[0m,\n",
  551. " \u001b[1;34m\"correct#acc\"\u001b[0m: \u001b[1;36m128.0\u001b[0m\n",
  552. "\u001b[1m}\u001b[0m\n"
  553. ]
  554. },
  555. "metadata": {},
  556. "output_type": "display_data"
  557. },
  558. {
  559. "data": {
  560. "text/html": [
  561. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  562. "</pre>\n"
  563. ],
  564. "text/plain": [
  565. "\n"
  566. ]
  567. },
  568. "metadata": {},
  569. "output_type": "display_data"
  570. },
  571. {
  572. "data": {
  573. "text/html": [
  574. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">----------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">4</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span> -----------------------------\n",
  575. "</pre>\n"
  576. ],
  577. "text/plain": [
  578. "----------------------------- Eval. results on Epoch:\u001b[1;36m4\u001b[0m, Batch:\u001b[1;36m0\u001b[0m -----------------------------\n"
  579. ]
  580. },
  581. "metadata": {},
  582. "output_type": "display_data"
  583. },
  584. {
  585. "data": {
  586. "text/html": [
  587. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  588. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.79375</span>,\n",
  589. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">160.0</span>,\n",
  590. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">127.0</span>\n",
  591. "<span style=\"font-weight: bold\">}</span>\n",
  592. "</pre>\n"
  593. ],
  594. "text/plain": [
  595. "\u001b[1m{\u001b[0m\n",
  596. " \u001b[1;34m\"acc#acc\"\u001b[0m: \u001b[1;36m0.79375\u001b[0m,\n",
  597. " \u001b[1;34m\"total#acc\"\u001b[0m: \u001b[1;36m160.0\u001b[0m,\n",
  598. " \u001b[1;34m\"correct#acc\"\u001b[0m: \u001b[1;36m127.0\u001b[0m\n",
  599. "\u001b[1m}\u001b[0m\n"
  600. ]
  601. },
  602. "metadata": {},
  603. "output_type": "display_data"
  604. },
  605. {
  606. "data": {
  607. "text/html": [
  608. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  609. "</pre>\n"
  610. ],
  611. "text/plain": [
  612. "\n"
  613. ]
  614. },
  615. "metadata": {},
  616. "output_type": "display_data"
  617. },
  618. {
  619. "data": {
  620. "text/html": [
  621. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">----------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span> -----------------------------\n",
  622. "</pre>\n"
  623. ],
  624. "text/plain": [
  625. "----------------------------- Eval. results on Epoch:\u001b[1;36m5\u001b[0m, Batch:\u001b[1;36m0\u001b[0m -----------------------------\n"
  626. ]
  627. },
  628. "metadata": {},
  629. "output_type": "display_data"
  630. },
  631. {
  632. "data": {
  633. "text/html": [
  634. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  635. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.81875</span>,\n",
  636. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">160.0</span>,\n",
  637. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">131.0</span>\n",
  638. "<span style=\"font-weight: bold\">}</span>\n",
  639. "</pre>\n"
  640. ],
  641. "text/plain": [
  642. "\u001b[1m{\u001b[0m\n",
  643. " \u001b[1;34m\"acc#acc\"\u001b[0m: \u001b[1;36m0.81875\u001b[0m,\n",
  644. " \u001b[1;34m\"total#acc\"\u001b[0m: \u001b[1;36m160.0\u001b[0m,\n",
  645. " \u001b[1;34m\"correct#acc\"\u001b[0m: \u001b[1;36m131.0\u001b[0m\n",
  646. "\u001b[1m}\u001b[0m\n"
  647. ]
  648. },
  649. "metadata": {},
  650. "output_type": "display_data"
  651. },
  652. {
  653. "data": {
  654. "text/html": [
  655. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  656. "</pre>\n"
  657. ],
  658. "text/plain": [
  659. "\n"
  660. ]
  661. },
  662. "metadata": {},
  663. "output_type": "display_data"
  664. },
  665. {
  666. "data": {
  667. "text/html": [
  668. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">----------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">6</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span> -----------------------------\n",
  669. "</pre>\n"
  670. ],
  671. "text/plain": [
  672. "----------------------------- Eval. results on Epoch:\u001b[1;36m6\u001b[0m, Batch:\u001b[1;36m0\u001b[0m -----------------------------\n"
  673. ]
  674. },
  675. "metadata": {},
  676. "output_type": "display_data"
  677. },
  678. {
  679. "data": {
  680. "text/html": [
  681. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  682. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.8</span>,\n",
  683. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">160.0</span>,\n",
  684. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">128.0</span>\n",
  685. "<span style=\"font-weight: bold\">}</span>\n",
  686. "</pre>\n"
  687. ],
  688. "text/plain": [
  689. "\u001b[1m{\u001b[0m\n",
  690. " \u001b[1;34m\"acc#acc\"\u001b[0m: \u001b[1;36m0.8\u001b[0m,\n",
  691. " \u001b[1;34m\"total#acc\"\u001b[0m: \u001b[1;36m160.0\u001b[0m,\n",
  692. " \u001b[1;34m\"correct#acc\"\u001b[0m: \u001b[1;36m128.0\u001b[0m\n",
  693. "\u001b[1m}\u001b[0m\n"
  694. ]
  695. },
  696. "metadata": {},
  697. "output_type": "display_data"
  698. },
  699. {
  700. "data": {
  701. "text/html": [
  702. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  703. "</pre>\n"
  704. ],
  705. "text/plain": [
  706. "\n"
  707. ]
  708. },
  709. "metadata": {},
  710. "output_type": "display_data"
  711. },
  712. {
  713. "data": {
  714. "text/html": [
  715. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">----------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">7</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span> -----------------------------\n",
  716. "</pre>\n"
  717. ],
  718. "text/plain": [
  719. "----------------------------- Eval. results on Epoch:\u001b[1;36m7\u001b[0m, Batch:\u001b[1;36m0\u001b[0m -----------------------------\n"
  720. ]
  721. },
  722. "metadata": {},
  723. "output_type": "display_data"
  724. },
  725. {
  726. "data": {
  727. "text/html": [
  728. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  729. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.80625</span>,\n",
  730. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">160.0</span>,\n",
  731. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">129.0</span>\n",
  732. "<span style=\"font-weight: bold\">}</span>\n",
  733. "</pre>\n"
  734. ],
  735. "text/plain": [
  736. "\u001b[1m{\u001b[0m\n",
  737. " \u001b[1;34m\"acc#acc\"\u001b[0m: \u001b[1;36m0.80625\u001b[0m,\n",
  738. " \u001b[1;34m\"total#acc\"\u001b[0m: \u001b[1;36m160.0\u001b[0m,\n",
  739. " \u001b[1;34m\"correct#acc\"\u001b[0m: \u001b[1;36m129.0\u001b[0m\n",
  740. "\u001b[1m}\u001b[0m\n"
  741. ]
  742. },
  743. "metadata": {},
  744. "output_type": "display_data"
  745. },
  746. {
  747. "data": {
  748. "text/html": [
  749. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  750. "</pre>\n"
  751. ],
  752. "text/plain": [
  753. "\n"
  754. ]
  755. },
  756. "metadata": {},
  757. "output_type": "display_data"
  758. },
  759. {
  760. "data": {
  761. "text/html": [
  762. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">----------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">8</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span> -----------------------------\n",
  763. "</pre>\n"
  764. ],
  765. "text/plain": [
  766. "----------------------------- Eval. results on Epoch:\u001b[1;36m8\u001b[0m, Batch:\u001b[1;36m0\u001b[0m -----------------------------\n"
  767. ]
  768. },
  769. "metadata": {},
  770. "output_type": "display_data"
  771. },
  772. {
  773. "data": {
  774. "text/html": [
  775. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  776. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.79375</span>,\n",
  777. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">160.0</span>,\n",
  778. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">127.0</span>\n",
  779. "<span style=\"font-weight: bold\">}</span>\n",
  780. "</pre>\n"
  781. ],
  782. "text/plain": [
  783. "\u001b[1m{\u001b[0m\n",
  784. " \u001b[1;34m\"acc#acc\"\u001b[0m: \u001b[1;36m0.79375\u001b[0m,\n",
  785. " \u001b[1;34m\"total#acc\"\u001b[0m: \u001b[1;36m160.0\u001b[0m,\n",
  786. " \u001b[1;34m\"correct#acc\"\u001b[0m: \u001b[1;36m127.0\u001b[0m\n",
  787. "\u001b[1m}\u001b[0m\n"
  788. ]
  789. },
  790. "metadata": {},
  791. "output_type": "display_data"
  792. },
  793. {
  794. "data": {
  795. "text/html": [
  796. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  797. "</pre>\n"
  798. ],
  799. "text/plain": [
  800. "\n"
  801. ]
  802. },
  803. "metadata": {},
  804. "output_type": "display_data"
  805. },
  806. {
  807. "data": {
  808. "text/html": [
  809. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">----------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">9</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span> -----------------------------\n",
  810. "</pre>\n"
  811. ],
  812. "text/plain": [
  813. "----------------------------- Eval. results on Epoch:\u001b[1;36m9\u001b[0m, Batch:\u001b[1;36m0\u001b[0m -----------------------------\n"
  814. ]
  815. },
  816. "metadata": {},
  817. "output_type": "display_data"
  818. },
  819. {
  820. "data": {
  821. "text/html": [
  822. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  823. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.7875</span>,\n",
  824. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">160.0</span>,\n",
  825. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">126.0</span>\n",
  826. "<span style=\"font-weight: bold\">}</span>\n",
  827. "</pre>\n"
  828. ],
  829. "text/plain": [
  830. "\u001b[1m{\u001b[0m\n",
  831. " \u001b[1;34m\"acc#acc\"\u001b[0m: \u001b[1;36m0.7875\u001b[0m,\n",
  832. " \u001b[1;34m\"total#acc\"\u001b[0m: \u001b[1;36m160.0\u001b[0m,\n",
  833. " \u001b[1;34m\"correct#acc\"\u001b[0m: \u001b[1;36m126.0\u001b[0m\n",
  834. "\u001b[1m}\u001b[0m\n"
  835. ]
  836. },
  837. "metadata": {},
  838. "output_type": "display_data"
  839. },
  840. {
  841. "data": {
  842. "text/html": [
  843. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  844. "</pre>\n"
  845. ],
  846. "text/plain": [
  847. "\n"
  848. ]
  849. },
  850. "metadata": {},
  851. "output_type": "display_data"
  852. },
  853. {
  854. "data": {
  855. "text/html": [
  856. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">---------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">10</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span> -----------------------------\n",
  857. "</pre>\n"
  858. ],
  859. "text/plain": [
  860. "---------------------------- Eval. results on Epoch:\u001b[1;36m10\u001b[0m, Batch:\u001b[1;36m0\u001b[0m -----------------------------\n"
  861. ]
  862. },
  863. "metadata": {},
  864. "output_type": "display_data"
  865. },
  866. {
  867. "data": {
  868. "text/html": [
  869. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  870. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.8</span>,\n",
  871. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">160.0</span>,\n",
  872. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">128.0</span>\n",
  873. "<span style=\"font-weight: bold\">}</span>\n",
  874. "</pre>\n"
  875. ],
  876. "text/plain": [
  877. "\u001b[1m{\u001b[0m\n",
  878. " \u001b[1;34m\"acc#acc\"\u001b[0m: \u001b[1;36m0.8\u001b[0m,\n",
  879. " \u001b[1;34m\"total#acc\"\u001b[0m: \u001b[1;36m160.0\u001b[0m,\n",
  880. " \u001b[1;34m\"correct#acc\"\u001b[0m: \u001b[1;36m128.0\u001b[0m\n",
  881. "\u001b[1m}\u001b[0m\n"
  882. ]
  883. },
  884. "metadata": {},
  885. "output_type": "display_data"
  886. },
  887. {
  888. "data": {
  889. "text/html": [
  890. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
  891. ],
  892. "text/plain": []
  893. },
  894. "metadata": {},
  895. "output_type": "display_data"
  896. },
  897. {
  898. "data": {
  899. "text/html": [
  900. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  901. "</pre>\n"
  902. ],
  903. "text/plain": [
  904. "\n"
  905. ]
  906. },
  907. "metadata": {},
  908. "output_type": "display_data"
  909. }
  910. ],
  911. "source": [
  912. "trainer.run(num_eval_batch_per_dl=10) "
  913. ]
  914. },
  915. {
  916. "cell_type": "markdown",
  917. "id": "cb9a0b3c",
  918. "metadata": {},
  919. "source": [
  920. "## 2. fastNLP 结合 jittor 训练模型"
  921. ]
  922. },
  923. {
  924. "cell_type": "code",
  925. "execution_count": 11,
  926. "id": "c600191d",
  927. "metadata": {},
  928. "outputs": [],
  929. "source": [
  930. "import jittor\n",
  931. "import jittor.nn as nn\n",
  932. "\n",
  933. "from jittor import Module\n",
  934. "\n",
  935. "\n",
  936. "class ClsByJittor(Module):\n",
  937. " def __init__(self, vocab_size, embedding_dim, output_dim, hidden_dim=64, num_layers=2, dropout=0.5):\n",
  938. " Module.__init__(self)\n",
  939. " self.hidden_dim = hidden_dim\n",
  940. "\n",
  941. " self.embedding = nn.Embedding(num=vocab_size, dim=embedding_dim)\n",
  942. " self.lstm = nn.LSTM(input_size=embedding_dim, hidden_size=hidden_dim, batch_first=True, # 默认 batch_first=False\n",
  943. " num_layers=num_layers, bidirectional=True, dropout=dropout)\n",
  944. " self.mlp = nn.Sequential([nn.Dropout(p=dropout),\n",
  945. " nn.Linear(hidden_dim * 2, hidden_dim * 2),\n",
  946. " nn.ReLU(),\n",
  947. " nn.Linear(hidden_dim * 2, output_dim),\n",
  948. " nn.Sigmoid(),])\n",
  949. "\n",
  950. " self.loss_fn = nn.MSELoss()\n",
  951. "\n",
  952. " def execute(self, words):\n",
  953. " output = self.embedding(words)\n",
  954. " output, (hidden, cell) = self.lstm(output)\n",
  955. " output = self.mlp(jittor.concat((hidden[-1], hidden[-2]), dim=1))\n",
  956. " return output\n",
  957. " \n",
  958. " def train_step(self, words, target):\n",
  959. " pred = self(words)\n",
  960. " target = jittor.stack((1 - target, target), dim=1)\n",
  961. " return {'loss': self.loss_fn(pred, target)}\n",
  962. "\n",
  963. " def evaluate_step(self, words, target):\n",
  964. " pred = self(words)\n",
  965. " pred = jittor.argmax(pred, dim=-1)[0]\n",
  966. " return {'pred': pred, 'target': target}"
  967. ]
  968. },
  969. {
  970. "cell_type": "code",
  971. "execution_count": 12,
  972. "id": "a94ed8c4",
  973. "metadata": {},
  974. "outputs": [
  975. {
  976. "data": {
  977. "text/plain": [
  978. "ClsByJittor(\n",
  979. " embedding: Embedding(8458, 100)\n",
  980. " lstm: LSTM(100, 64, 2, bias=True, batch_first=True, dropout=0.5, bidirectional=True, proj_size=0)\n",
  981. " mlp: Sequential(\n",
  982. " 0: Dropout(0.5, is_train=False)\n",
  983. " 1: Linear(128, 128, float32[128,], None)\n",
  984. " 2: relu()\n",
  985. " 3: Linear(128, 2, float32[2,], None)\n",
  986. " 4: Sigmoid()\n",
  987. " )\n",
  988. " loss_fn: MSELoss(mean)\n",
  989. ")"
  990. ]
  991. },
  992. "execution_count": 12,
  993. "metadata": {},
  994. "output_type": "execute_result"
  995. }
  996. ],
  997. "source": [
  998. "model = ClsByJittor(vocab_size=len(vocab), embedding_dim=100, output_dim=2)\n",
  999. "\n",
  1000. "model"
  1001. ]
  1002. },
  1003. {
  1004. "cell_type": "code",
  1005. "execution_count": 13,
  1006. "id": "6d15ebc1",
  1007. "metadata": {},
  1008. "outputs": [],
  1009. "source": [
  1010. "from jittor.optim import AdamW\n",
  1011. "\n",
  1012. "optimizers = AdamW(params=model.parameters(), lr=5e-3)"
  1013. ]
  1014. },
  1015. {
  1016. "cell_type": "code",
  1017. "execution_count": 14,
  1018. "id": "95d8d09e",
  1019. "metadata": {},
  1020. "outputs": [],
  1021. "source": [
  1022. "from fastNLP import prepare_jittor_dataloader\n",
  1023. "\n",
  1024. "train_dataloader = prepare_jittor_dataloader(train_dataset, batch_size=16, shuffle=True)\n",
  1025. "evaluate_dataloader = prepare_jittor_dataloader(evaluate_dataset, batch_size=16)\n",
  1026. "\n",
  1027. "# dl_bundle = prepare_jittor_dataloader(data_bundle, batch_size=16, shuffle=True)"
  1028. ]
  1029. },
  1030. {
  1031. "cell_type": "code",
  1032. "execution_count": 15,
  1033. "id": "917eab81",
  1034. "metadata": {},
  1035. "outputs": [],
  1036. "source": [
  1037. "from fastNLP import Trainer, Accuracy\n",
  1038. "\n",
  1039. "trainer = Trainer(\n",
  1040. " model=model,\n",
  1041. " driver='jittor',\n",
  1042. " device='gpu', # 'cpu', 'gpu', 'cuda'\n",
  1043. " n_epochs=10,\n",
  1044. " optimizers=optimizers,\n",
  1045. " train_dataloader=train_dataloader, # dl_bundle['train'],\n",
  1046. " evaluate_dataloaders=evaluate_dataloader, # dl_bundle['dev'],\n",
  1047. " metrics={'acc': Accuracy()}\n",
  1048. ")"
  1049. ]
  1050. },
  1051. {
  1052. "cell_type": "code",
  1053. "execution_count": 16,
  1054. "id": "f7c4ac5a",
  1055. "metadata": {},
  1056. "outputs": [
  1057. {
  1058. "data": {
  1059. "text/html": [
  1060. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7fbfbf; text-decoration-color: #7fbfbf\">[21:05:51] </span><span style=\"color: #000080; text-decoration-color: #000080\">INFO </span> Running evaluator sanity check for <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span> batches. <a href=\"file://../fastNLP/core/controllers/trainer.py\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">trainer.py</span></a><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">:</span><a href=\"file://../fastNLP/core/controllers/trainer.py#596\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">596</span></a>\n",
  1061. "</pre>\n"
  1062. ],
  1063. "text/plain": [
  1064. "\u001b[2;36m[21:05:51]\u001b[0m\u001b[2;36m \u001b[0m\u001b[34mINFO \u001b[0m Running evaluator sanity check for \u001b[1;36m2\u001b[0m batches. \u001b]8;id=69759;file://../fastNLP/core/controllers/trainer.py\u001b\\\u001b[2mtrainer.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=202322;file://../fastNLP/core/controllers/trainer.py#596\u001b\\\u001b[2m596\u001b[0m\u001b]8;;\u001b\\\n"
  1065. ]
  1066. },
  1067. "metadata": {},
  1068. "output_type": "display_data"
  1069. },
  1070. {
  1071. "data": {
  1072. "application/vnd.jupyter.widget-view+json": {
  1073. "model_id": "",
  1074. "version_major": 2,
  1075. "version_minor": 0
  1076. },
  1077. "text/plain": [
  1078. "Output()"
  1079. ]
  1080. },
  1081. "metadata": {},
  1082. "output_type": "display_data"
  1083. },
  1084. {
  1085. "data": {
  1086. "text/html": [
  1087. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
  1088. ],
  1089. "text/plain": []
  1090. },
  1091. "metadata": {},
  1092. "output_type": "display_data"
  1093. },
  1094. {
  1095. "data": {
  1096. "application/vnd.jupyter.widget-view+json": {
  1097. "model_id": "",
  1098. "version_major": 2,
  1099. "version_minor": 0
  1100. },
  1101. "text/plain": [
  1102. "Output()"
  1103. ]
  1104. },
  1105. "metadata": {},
  1106. "output_type": "display_data"
  1107. },
  1108. {
  1109. "name": "stderr",
  1110. "output_type": "stream",
  1111. "text": [
  1112. "\n",
  1113. "Compiling Operators(5/6) used: 8.31s eta: 1.66s 6/6) used: 9.33s eta: 0s \n",
  1114. "\n",
  1115. "Compiling Operators(31/31) used: 7.31s eta: 0s \n"
  1116. ]
  1117. },
  1118. {
  1119. "data": {
  1120. "text/html": [
  1121. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  1122. "</pre>\n"
  1123. ],
  1124. "text/plain": [
  1125. "\n"
  1126. ]
  1127. },
  1128. "metadata": {},
  1129. "output_type": "display_data"
  1130. },
  1131. {
  1132. "data": {
  1133. "text/html": [
  1134. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">----------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span> -----------------------------\n",
  1135. "</pre>\n"
  1136. ],
  1137. "text/plain": [
  1138. "----------------------------- Eval. results on Epoch:\u001b[1;36m1\u001b[0m, Batch:\u001b[1;36m0\u001b[0m -----------------------------\n"
  1139. ]
  1140. },
  1141. "metadata": {},
  1142. "output_type": "display_data"
  1143. },
  1144. {
  1145. "data": {
  1146. "text/html": [
  1147. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  1148. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.61875</span>,\n",
  1149. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">160</span>,\n",
  1150. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">99</span>\n",
  1151. "<span style=\"font-weight: bold\">}</span>\n",
  1152. "</pre>\n"
  1153. ],
  1154. "text/plain": [
  1155. "\u001b[1m{\u001b[0m\n",
  1156. " \u001b[1;34m\"acc#acc\"\u001b[0m: \u001b[1;36m0.61875\u001b[0m,\n",
  1157. " \u001b[1;34m\"total#acc\"\u001b[0m: \u001b[1;36m160\u001b[0m,\n",
  1158. " \u001b[1;34m\"correct#acc\"\u001b[0m: \u001b[1;36m99\u001b[0m\n",
  1159. "\u001b[1m}\u001b[0m\n"
  1160. ]
  1161. },
  1162. "metadata": {},
  1163. "output_type": "display_data"
  1164. },
  1165. {
  1166. "data": {
  1167. "text/html": [
  1168. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  1169. "</pre>\n"
  1170. ],
  1171. "text/plain": [
  1172. "\n"
  1173. ]
  1174. },
  1175. "metadata": {},
  1176. "output_type": "display_data"
  1177. },
  1178. {
  1179. "data": {
  1180. "text/html": [
  1181. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">----------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span> -----------------------------\n",
  1182. "</pre>\n"
  1183. ],
  1184. "text/plain": [
  1185. "----------------------------- Eval. results on Epoch:\u001b[1;36m2\u001b[0m, Batch:\u001b[1;36m0\u001b[0m -----------------------------\n"
  1186. ]
  1187. },
  1188. "metadata": {},
  1189. "output_type": "display_data"
  1190. },
  1191. {
  1192. "data": {
  1193. "text/html": [
  1194. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  1195. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.7</span>,\n",
  1196. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">160</span>,\n",
  1197. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">112</span>\n",
  1198. "<span style=\"font-weight: bold\">}</span>\n",
  1199. "</pre>\n"
  1200. ],
  1201. "text/plain": [
  1202. "\u001b[1m{\u001b[0m\n",
  1203. " \u001b[1;34m\"acc#acc\"\u001b[0m: \u001b[1;36m0.7\u001b[0m,\n",
  1204. " \u001b[1;34m\"total#acc\"\u001b[0m: \u001b[1;36m160\u001b[0m,\n",
  1205. " \u001b[1;34m\"correct#acc\"\u001b[0m: \u001b[1;36m112\u001b[0m\n",
  1206. "\u001b[1m}\u001b[0m\n"
  1207. ]
  1208. },
  1209. "metadata": {},
  1210. "output_type": "display_data"
  1211. },
  1212. {
  1213. "data": {
  1214. "text/html": [
  1215. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  1216. "</pre>\n"
  1217. ],
  1218. "text/plain": [
  1219. "\n"
  1220. ]
  1221. },
  1222. "metadata": {},
  1223. "output_type": "display_data"
  1224. },
  1225. {
  1226. "data": {
  1227. "text/html": [
  1228. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">----------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">3</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span> -----------------------------\n",
  1229. "</pre>\n"
  1230. ],
  1231. "text/plain": [
  1232. "----------------------------- Eval. results on Epoch:\u001b[1;36m3\u001b[0m, Batch:\u001b[1;36m0\u001b[0m -----------------------------\n"
  1233. ]
  1234. },
  1235. "metadata": {},
  1236. "output_type": "display_data"
  1237. },
  1238. {
  1239. "data": {
  1240. "text/html": [
  1241. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  1242. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.725</span>,\n",
  1243. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">160</span>,\n",
  1244. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">116</span>\n",
  1245. "<span style=\"font-weight: bold\">}</span>\n",
  1246. "</pre>\n"
  1247. ],
  1248. "text/plain": [
  1249. "\u001b[1m{\u001b[0m\n",
  1250. " \u001b[1;34m\"acc#acc\"\u001b[0m: \u001b[1;36m0.725\u001b[0m,\n",
  1251. " \u001b[1;34m\"total#acc\"\u001b[0m: \u001b[1;36m160\u001b[0m,\n",
  1252. " \u001b[1;34m\"correct#acc\"\u001b[0m: \u001b[1;36m116\u001b[0m\n",
  1253. "\u001b[1m}\u001b[0m\n"
  1254. ]
  1255. },
  1256. "metadata": {},
  1257. "output_type": "display_data"
  1258. },
  1259. {
  1260. "data": {
  1261. "text/html": [
  1262. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  1263. "</pre>\n"
  1264. ],
  1265. "text/plain": [
  1266. "\n"
  1267. ]
  1268. },
  1269. "metadata": {},
  1270. "output_type": "display_data"
  1271. },
  1272. {
  1273. "data": {
  1274. "text/html": [
  1275. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">----------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">4</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span> -----------------------------\n",
  1276. "</pre>\n"
  1277. ],
  1278. "text/plain": [
  1279. "----------------------------- Eval. results on Epoch:\u001b[1;36m4\u001b[0m, Batch:\u001b[1;36m0\u001b[0m -----------------------------\n"
  1280. ]
  1281. },
  1282. "metadata": {},
  1283. "output_type": "display_data"
  1284. },
  1285. {
  1286. "data": {
  1287. "text/html": [
  1288. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  1289. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.74375</span>,\n",
  1290. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">160</span>,\n",
  1291. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">119</span>\n",
  1292. "<span style=\"font-weight: bold\">}</span>\n",
  1293. "</pre>\n"
  1294. ],
  1295. "text/plain": [
  1296. "\u001b[1m{\u001b[0m\n",
  1297. " \u001b[1;34m\"acc#acc\"\u001b[0m: \u001b[1;36m0.74375\u001b[0m,\n",
  1298. " \u001b[1;34m\"total#acc\"\u001b[0m: \u001b[1;36m160\u001b[0m,\n",
  1299. " \u001b[1;34m\"correct#acc\"\u001b[0m: \u001b[1;36m119\u001b[0m\n",
  1300. "\u001b[1m}\u001b[0m\n"
  1301. ]
  1302. },
  1303. "metadata": {},
  1304. "output_type": "display_data"
  1305. },
  1306. {
  1307. "data": {
  1308. "text/html": [
  1309. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  1310. "</pre>\n"
  1311. ],
  1312. "text/plain": [
  1313. "\n"
  1314. ]
  1315. },
  1316. "metadata": {},
  1317. "output_type": "display_data"
  1318. },
  1319. {
  1320. "data": {
  1321. "text/html": [
  1322. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">----------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span> -----------------------------\n",
  1323. "</pre>\n"
  1324. ],
  1325. "text/plain": [
  1326. "----------------------------- Eval. results on Epoch:\u001b[1;36m5\u001b[0m, Batch:\u001b[1;36m0\u001b[0m -----------------------------\n"
  1327. ]
  1328. },
  1329. "metadata": {},
  1330. "output_type": "display_data"
  1331. },
  1332. {
  1333. "data": {
  1334. "text/html": [
  1335. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  1336. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.75625</span>,\n",
  1337. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">160</span>,\n",
  1338. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">121</span>\n",
  1339. "<span style=\"font-weight: bold\">}</span>\n",
  1340. "</pre>\n"
  1341. ],
  1342. "text/plain": [
  1343. "\u001b[1m{\u001b[0m\n",
  1344. " \u001b[1;34m\"acc#acc\"\u001b[0m: \u001b[1;36m0.75625\u001b[0m,\n",
  1345. " \u001b[1;34m\"total#acc\"\u001b[0m: \u001b[1;36m160\u001b[0m,\n",
  1346. " \u001b[1;34m\"correct#acc\"\u001b[0m: \u001b[1;36m121\u001b[0m\n",
  1347. "\u001b[1m}\u001b[0m\n"
  1348. ]
  1349. },
  1350. "metadata": {},
  1351. "output_type": "display_data"
  1352. },
  1353. {
  1354. "data": {
  1355. "text/html": [
  1356. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  1357. "</pre>\n"
  1358. ],
  1359. "text/plain": [
  1360. "\n"
  1361. ]
  1362. },
  1363. "metadata": {},
  1364. "output_type": "display_data"
  1365. },
  1366. {
  1367. "data": {
  1368. "text/html": [
  1369. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">----------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">6</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span> -----------------------------\n",
  1370. "</pre>\n"
  1371. ],
  1372. "text/plain": [
  1373. "----------------------------- Eval. results on Epoch:\u001b[1;36m6\u001b[0m, Batch:\u001b[1;36m0\u001b[0m -----------------------------\n"
  1374. ]
  1375. },
  1376. "metadata": {},
  1377. "output_type": "display_data"
  1378. },
  1379. {
  1380. "data": {
  1381. "text/html": [
  1382. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  1383. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.75625</span>,\n",
  1384. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">160</span>,\n",
  1385. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">121</span>\n",
  1386. "<span style=\"font-weight: bold\">}</span>\n",
  1387. "</pre>\n"
  1388. ],
  1389. "text/plain": [
  1390. "\u001b[1m{\u001b[0m\n",
  1391. " \u001b[1;34m\"acc#acc\"\u001b[0m: \u001b[1;36m0.75625\u001b[0m,\n",
  1392. " \u001b[1;34m\"total#acc\"\u001b[0m: \u001b[1;36m160\u001b[0m,\n",
  1393. " \u001b[1;34m\"correct#acc\"\u001b[0m: \u001b[1;36m121\u001b[0m\n",
  1394. "\u001b[1m}\u001b[0m\n"
  1395. ]
  1396. },
  1397. "metadata": {},
  1398. "output_type": "display_data"
  1399. },
  1400. {
  1401. "data": {
  1402. "text/html": [
  1403. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  1404. "</pre>\n"
  1405. ],
  1406. "text/plain": [
  1407. "\n"
  1408. ]
  1409. },
  1410. "metadata": {},
  1411. "output_type": "display_data"
  1412. },
  1413. {
  1414. "data": {
  1415. "text/html": [
  1416. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">----------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">7</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span> -----------------------------\n",
  1417. "</pre>\n"
  1418. ],
  1419. "text/plain": [
  1420. "----------------------------- Eval. results on Epoch:\u001b[1;36m7\u001b[0m, Batch:\u001b[1;36m0\u001b[0m -----------------------------\n"
  1421. ]
  1422. },
  1423. "metadata": {},
  1424. "output_type": "display_data"
  1425. },
  1426. {
  1427. "data": {
  1428. "text/html": [
  1429. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  1430. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.73125</span>,\n",
  1431. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">160</span>,\n",
  1432. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">117</span>\n",
  1433. "<span style=\"font-weight: bold\">}</span>\n",
  1434. "</pre>\n"
  1435. ],
  1436. "text/plain": [
  1437. "\u001b[1m{\u001b[0m\n",
  1438. " \u001b[1;34m\"acc#acc\"\u001b[0m: \u001b[1;36m0.73125\u001b[0m,\n",
  1439. " \u001b[1;34m\"total#acc\"\u001b[0m: \u001b[1;36m160\u001b[0m,\n",
  1440. " \u001b[1;34m\"correct#acc\"\u001b[0m: \u001b[1;36m117\u001b[0m\n",
  1441. "\u001b[1m}\u001b[0m\n"
  1442. ]
  1443. },
  1444. "metadata": {},
  1445. "output_type": "display_data"
  1446. },
  1447. {
  1448. "data": {
  1449. "text/html": [
  1450. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  1451. "</pre>\n"
  1452. ],
  1453. "text/plain": [
  1454. "\n"
  1455. ]
  1456. },
  1457. "metadata": {},
  1458. "output_type": "display_data"
  1459. },
  1460. {
  1461. "data": {
  1462. "text/html": [
  1463. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">----------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">8</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span> -----------------------------\n",
  1464. "</pre>\n"
  1465. ],
  1466. "text/plain": [
  1467. "----------------------------- Eval. results on Epoch:\u001b[1;36m8\u001b[0m, Batch:\u001b[1;36m0\u001b[0m -----------------------------\n"
  1468. ]
  1469. },
  1470. "metadata": {},
  1471. "output_type": "display_data"
  1472. },
  1473. {
  1474. "data": {
  1475. "text/html": [
  1476. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  1477. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.7625</span>,\n",
  1478. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">160</span>,\n",
  1479. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">122</span>\n",
  1480. "<span style=\"font-weight: bold\">}</span>\n",
  1481. "</pre>\n"
  1482. ],
  1483. "text/plain": [
  1484. "\u001b[1m{\u001b[0m\n",
  1485. " \u001b[1;34m\"acc#acc\"\u001b[0m: \u001b[1;36m0.7625\u001b[0m,\n",
  1486. " \u001b[1;34m\"total#acc\"\u001b[0m: \u001b[1;36m160\u001b[0m,\n",
  1487. " \u001b[1;34m\"correct#acc\"\u001b[0m: \u001b[1;36m122\u001b[0m\n",
  1488. "\u001b[1m}\u001b[0m\n"
  1489. ]
  1490. },
  1491. "metadata": {},
  1492. "output_type": "display_data"
  1493. },
  1494. {
  1495. "data": {
  1496. "text/html": [
  1497. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  1498. "</pre>\n"
  1499. ],
  1500. "text/plain": [
  1501. "\n"
  1502. ]
  1503. },
  1504. "metadata": {},
  1505. "output_type": "display_data"
  1506. },
  1507. {
  1508. "data": {
  1509. "text/html": [
  1510. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">----------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">9</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span> -----------------------------\n",
  1511. "</pre>\n"
  1512. ],
  1513. "text/plain": [
  1514. "----------------------------- Eval. results on Epoch:\u001b[1;36m9\u001b[0m, Batch:\u001b[1;36m0\u001b[0m -----------------------------\n"
  1515. ]
  1516. },
  1517. "metadata": {},
  1518. "output_type": "display_data"
  1519. },
  1520. {
  1521. "data": {
  1522. "text/html": [
  1523. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  1524. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.74375</span>,\n",
  1525. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">160</span>,\n",
  1526. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">119</span>\n",
  1527. "<span style=\"font-weight: bold\">}</span>\n",
  1528. "</pre>\n"
  1529. ],
  1530. "text/plain": [
  1531. "\u001b[1m{\u001b[0m\n",
  1532. " \u001b[1;34m\"acc#acc\"\u001b[0m: \u001b[1;36m0.74375\u001b[0m,\n",
  1533. " \u001b[1;34m\"total#acc\"\u001b[0m: \u001b[1;36m160\u001b[0m,\n",
  1534. " \u001b[1;34m\"correct#acc\"\u001b[0m: \u001b[1;36m119\u001b[0m\n",
  1535. "\u001b[1m}\u001b[0m\n"
  1536. ]
  1537. },
  1538. "metadata": {},
  1539. "output_type": "display_data"
  1540. },
  1541. {
  1542. "data": {
  1543. "text/html": [
  1544. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  1545. "</pre>\n"
  1546. ],
  1547. "text/plain": [
  1548. "\n"
  1549. ]
  1550. },
  1551. "metadata": {},
  1552. "output_type": "display_data"
  1553. },
  1554. {
  1555. "data": {
  1556. "text/html": [
  1557. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">---------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">10</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span> -----------------------------\n",
  1558. "</pre>\n"
  1559. ],
  1560. "text/plain": [
  1561. "---------------------------- Eval. results on Epoch:\u001b[1;36m10\u001b[0m, Batch:\u001b[1;36m0\u001b[0m -----------------------------\n"
  1562. ]
  1563. },
  1564. "metadata": {},
  1565. "output_type": "display_data"
  1566. },
  1567. {
  1568. "data": {
  1569. "text/html": [
  1570. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  1571. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.7625</span>,\n",
  1572. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">160</span>,\n",
  1573. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#acc\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">122</span>\n",
  1574. "<span style=\"font-weight: bold\">}</span>\n",
  1575. "</pre>\n"
  1576. ],
  1577. "text/plain": [
  1578. "\u001b[1m{\u001b[0m\n",
  1579. " \u001b[1;34m\"acc#acc\"\u001b[0m: \u001b[1;36m0.7625\u001b[0m,\n",
  1580. " \u001b[1;34m\"total#acc\"\u001b[0m: \u001b[1;36m160\u001b[0m,\n",
  1581. " \u001b[1;34m\"correct#acc\"\u001b[0m: \u001b[1;36m122\u001b[0m\n",
  1582. "\u001b[1m}\u001b[0m\n"
  1583. ]
  1584. },
  1585. "metadata": {},
  1586. "output_type": "display_data"
  1587. },
  1588. {
  1589. "data": {
  1590. "text/html": [
  1591. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
  1592. ],
  1593. "text/plain": []
  1594. },
  1595. "metadata": {},
  1596. "output_type": "display_data"
  1597. },
  1598. {
  1599. "data": {
  1600. "text/html": [
  1601. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  1602. "</pre>\n"
  1603. ],
  1604. "text/plain": [
  1605. "\n"
  1606. ]
  1607. },
  1608. "metadata": {},
  1609. "output_type": "display_data"
  1610. }
  1611. ],
  1612. "source": [
  1613. "trainer.run(num_eval_batch_per_dl=10)"
  1614. ]
  1615. },
  1616. {
  1617. "cell_type": "code",
  1618. "execution_count": null,
  1619. "id": "3df5f425",
  1620. "metadata": {},
  1621. "outputs": [],
  1622. "source": []
  1623. }
  1624. ],
  1625. "metadata": {
  1626. "kernelspec": {
  1627. "display_name": "Python 3 (ipykernel)",
  1628. "language": "python",
  1629. "name": "python3"
  1630. },
  1631. "language_info": {
  1632. "codemirror_mode": {
  1633. "name": "ipython",
  1634. "version": 3
  1635. },
  1636. "file_extension": ".py",
  1637. "mimetype": "text/x-python",
  1638. "name": "python",
  1639. "nbconvert_exporter": "python",
  1640. "pygments_lexer": "ipython3",
  1641. "version": "3.7.13"
  1642. }
  1643. },
  1644. "nbformat": 4,
  1645. "nbformat_minor": 5
  1646. }