Commit f6818002 authored by Ubuntu's avatar Ubuntu
Browse files

debugged the model, now train and runnable

parent 0815326a
......@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 316,
"execution_count": 78,
"metadata": {},
"outputs": [],
"source": [
......@@ -11,6 +11,7 @@
"from DataLoadingAPI.DataSetGenerator import increaseDims\n",
"from DataLoadingAPI.DataSetGenerator import getOneHotEncoding\n",
"from DataLoadingAPI.sensorDataKeys import getIMUKeys\n",
"\n",
"from numpy import NaN\n",
"import pandas as pd\n",
"import time\n",
......@@ -19,13 +20,15 @@
"import torch.nn as nn\n",
"import torch.nn.functional as F\n",
"import torch.optim as optim\n",
"from torch import Tensor\n",
"import numpy as np\n",
"import torch.utils.data as data_utils"
"import torch.utils.data as data_utils\n",
"from typing import Optional, Any"
]
},
{
"cell_type": "code",
"execution_count": 335,
"execution_count": 79,
"metadata": {
"pycharm": {
"name": "#%%\n"
......@@ -43,7 +46,10 @@
" self.softmax = nn.Softmax(dim=2)\n",
"\n",
"\n",
" def forward(self, x):\n",
" def forward(self, x, src_mask: Optional[Tensor] = None,\n",
" tgt_mask: Optional[Tensor] = None,\n",
" src_key_padding_mask: Optional[Tensor] = None,\n",
" tgt_key_padding_mask: Optional[Tensor] = None):\n",
"\n",
" #print(x[1].size(1))\n",
"\n",
......@@ -53,19 +59,24 @@
" \n",
" castTensor1.unsqueeze_(0)\n",
" castTensor2.unsqueeze_(0)\n",
" print(castTensor1.size())\n",
" print(castTensor2.size())\n",
" out = self.transformer(castTensor1,castTensor2)\n",
" out = self.fcLayer2(out)\n",
" \n",
"\n",
"\n",
" return out"
" return out\n",
" \n",
"def getKeyQueryMask(batch_size,look_back):\n",
" matrix = np.ones((batch_size,look_back))\n",
" tri_upper_diag = np.triu(matrix, k=0)\n",
" return torch.from_numpy(tri_upper_diag)\n",
"\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 336,
"execution_count": 80,
"metadata": {
"pycharm": {
"name": "#%%\n"
......@@ -91,16 +102,20 @@
" previousLabels = list()\n",
" for timeFrame in range(len(data)):\n",
" \n",
" prevSeq = previousLabels\n",
" prevSeq.append(targets[timeFrame])\n",
" \n",
" tuple = (torch.tensor(np.array(data[:(timeFrame+1)])), np.array(np.array(prevSeq)))\n",
" previousLabels.append(0)\n",
" \n",
" \n",
" tup = (torch.tensor(np.array(data[:(timeFrame+1)])), np.array(np.array(previousLabels)))\n",
" \n",
" optimizer.zero_grad()\n",
" output = net(tuple)\n",
" output = net(tup, src_mask=net.transformer.generate_square_subsequent_mask(len(data[:(timeFrame+1)])),\n",
" tgt_mask=net.transformer.generate_square_subsequent_mask(len(previousLabels)),\n",
" src_key_padding_mask=getKeyQueryMask((timeFrame+1),len(data[:(timeFrame+1)])),\n",
" tgt_key_padding_mask=getKeyQueryMask((timeFrame+1),len(previousLabels))\n",
" )\n",
" classProbs = net.softmax(output)\n",
" \n",
" probs = classProbs.detach().numpy()\n",
" previousLabels.append(np.argmax(probs))\n",
" np.insert(previousLabels,0, np.argmax(probs))\n",
" outputCopy = output\n",
" \n",
" targetTensor = torch.tensor(targets[:(timeFrame+1)]).type(dtype=torch.DoubleTensor)\n",
......@@ -140,7 +155,7 @@
},
{
"cell_type": "code",
"execution_count": 337,
"execution_count": 81,
"metadata": {
"pycharm": {
"is_executing": true,
......@@ -148,17 +163,6 @@
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"torch.Size([1, 1, 40])\n",
"torch.Size([1, 1, 40])\n",
"| recording 4 |timeframe: 0.0000lr 5.000000 | ms/recording 2171.17 | loss 0.694550\n",
"torch.Size([1, 2, 40])\n",
"torch.Size([1, 3, 40])\n"
]
},
{
"name": "stderr",
"output_type": "stream",
......@@ -168,19 +172,19 @@
]
},
{
"ename": "RuntimeError",
"evalue": "the batch number of src and tgt must be equal",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-337-498e238f49e9>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mbest_val_loss\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfloat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"inf\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mepoch_start_time\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtime\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtime\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----> 3\u001b[0;31m \u001b[0mtrain\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 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m<ipython-input-336-d110eab92eff>\u001b[0m in \u001b[0;36mtrain\u001b[0;34m()\u001b[0m\n\u001b[1;32m 22\u001b[0m \u001b[0mtuple\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mtorch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtensor\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtimeFrame\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;36m1\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[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mprevSeq\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[1;32m 23\u001b[0m \u001b[0moptimizer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mzero_grad\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---> 24\u001b[0;31m \u001b[0moutput\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnet\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtuple\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 25\u001b[0m \u001b[0mclassProbs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnet\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msoftmax\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0moutput\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 26\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.6/site-packages/torch/nn/modules/module.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, *input, **kwargs)\u001b[0m\n\u001b[1;32m 548\u001b[0m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_slow_forward\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0minput\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[1;32m 549\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--> 550\u001b[0;31m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mforward\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0minput\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 551\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mhook\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_forward_hooks\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalues\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[1;32m 552\u001b[0m \u001b[0mhook_result\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mhook\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0minput\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m<ipython-input-335-b6a5b585814d>\u001b[0m in \u001b[0;36mforward\u001b[0;34m(self, x)\u001b[0m\n\u001b[1;32m 21\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcastTensor1\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msize\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[1;32m 22\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcastTensor2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msize\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[0;32m---> 23\u001b[0;31m \u001b[0mout\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtransformer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcastTensor1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mcastTensor2\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 24\u001b[0m \u001b[0mout\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfcLayer2\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mout\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.6/site-packages/torch/nn/modules/module.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, *input, **kwargs)\u001b[0m\n\u001b[1;32m 548\u001b[0m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_slow_forward\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0minput\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[1;32m 549\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--> 550\u001b[0;31m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mforward\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0minput\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 551\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mhook\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_forward_hooks\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalues\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[1;32m 552\u001b[0m \u001b[0mhook_result\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mhook\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0minput\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.6/site-packages/torch/nn/modules/transformer.py\u001b[0m in \u001b[0;36mforward\u001b[0;34m(self, src, tgt, src_mask, tgt_mask, memory_mask, src_key_padding_mask, tgt_key_padding_mask, memory_key_padding_mask)\u001b[0m\n\u001b[1;32m 113\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 114\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0msrc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msize\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0mtgt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msize\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\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--> 115\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mRuntimeError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"the batch number of src and tgt must be equal\"\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 116\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 117\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0msrc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msize\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0md_model\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mtgt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msize\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0md_model\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mRuntimeError\u001b[0m: the batch number of src and tgt must be equal"
"name": "stdout",
"output_type": "stream",
"text": [
"| recording 4 |timeframe: 0.0000lr 5.000000 | ms/recording 2305.57 | loss 0.997833\n",
"| recording 4 |timeframe: 1.0000lr 5.000000 | ms/recording 2355.04 | loss 1.173332\n",
"| recording 4 |timeframe: 2.0000lr 5.000000 | ms/recording 2399.93 | loss 1.182373\n",
"| recording 4 |timeframe: 3.0000lr 5.000000 | ms/recording 2449.66 | loss 1.182379\n",
"| recording 4 |timeframe: 4.0000lr 5.000000 | ms/recording 2499.74 | loss 1.182384\n",
"| recording 4 |timeframe: 5.0000lr 5.000000 | ms/recording 2554.14 | loss 1.182391\n",
"| recording 4 |timeframe: 6.0000lr 5.000000 | ms/recording 2610.57 | loss 1.182397\n",
"| recording 4 |timeframe: 7.0000lr 5.000000 | ms/recording 2667.42 | loss 1.182402\n",
"| recording 4 |timeframe: 8.0000lr 5.000000 | ms/recording 2725.43 | loss 1.182407\n",
"| recording 4 |timeframe: 9.0000lr 5.000000 | ms/recording 2785.67 | loss 1.182413\n"
]
}
],
......@@ -193,7 +197,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 82,
"metadata": {
"pycharm": {
"name": "#%%\n"
......@@ -212,7 +216,11 @@
" targets = targets1[:10]\n",
" for timeFrame in range(len(data)):\n",
" tup = (torch.tensor(np.array(data[:(timeFrame+1)])), np.array(targets[:(timeFrame+1)]))\n",
" output = eval_model(tup)\n",
" output = net(tup, src_mask=net.transformer.generate_square_subsequent_mask(len(data[:(timeFrame+1)])),\n",
" tgt_mask=net.transformer.generate_square_subsequent_mask(len(previousLabels)),\n",
" src_key_padding_mask=getKeyQueryMask((timeFrame+1),len(data[:(timeFrame+1)])),\n",
" tgt_key_padding_mask=getKeyQueryMask((timeFrame+1),len(previousLabels))\n",
" )\n",
" targetTensor = torch.tensor(targets[:(timeFrame+1)]).type(dtype=torch.DoubleTensor)\n",
" outputCopy = output.squeeze(1)\n",
" crit= criterion(output.squeeze(0),targetTensor.type(torch.long))\n",
......@@ -224,9 +232,59 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 83,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"-----------------------------------------------------------------------------------------\n",
"| end of epoch 1 | time: 12.52s | valid loss 0.000358 | valid ppl 1.00\n",
"-----------------------------------------------------------------------------------------\n"
]
}
],
"source": [
"val_loss = evaluate(net, data_source_ending_index)\n",
"print('-' * 89)\n",
......@@ -244,14 +302,64 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 84,
"metadata": {
"pycharm": {
"is_executing": true,
"name": "#%%\n"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"tensor(3.5763e-06)\n",
"=========================================================================================\n",
"| End of training | test loss 0.000358 | test ppl 1.00\n",
"=========================================================================================\n"
]
}
],
"source": [
"test_loss = evaluate(best_model, data_source_ending_index)\n",
"print('=' * 89)\n",
......
This diff is collapsed.
File added
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment