This commit is contained in:
tlk-dsg 2021-09-16 16:03:29 +08:00
parent 3251e8eeda
commit 5acc7a5686
1 changed files with 19 additions and 9 deletions

View File

@ -33,7 +33,7 @@
"\n",
"![LSTM](img/LSTM.jpg)\n",
"\n",
"The sentence information mainly includes wording embedding.After the rnn layer,according to the position of entity,attribute key,it through the full connection layer, the attribution information of the sentence can be obtained."
"The sentence information mainly includes wording embedding.After the rnn layer,according to the position of entity,attribute key,it through the full connection layer, the attribution information of the sentence can be obtained.\n"
],
"metadata": {}
},
@ -417,10 +417,6 @@
"execution_count": null,
"source": [
"# embedding layer\n",
"import torch\n",
"import torch.nn as nn\n",
"\n",
"\n",
"class Embedding(nn.Module):\n",
" def __init__(self, config):\n",
" \"\"\"\n",
@ -479,7 +475,7 @@
"cell_type": "code",
"execution_count": null,
"source": [
"#rnn model\n",
"# cnn model\n",
"class RNN(nn.Module):\n",
" def __init__(self, config):\n",
" \"\"\"\n",
@ -547,7 +543,7 @@
" if self.last_layer_hn:\n",
" hn = hn[:, -1, :]\n",
"\n",
" return output, hn"
" return output, hn\n"
],
"outputs": [],
"metadata": {}
@ -623,6 +619,7 @@
"\n",
" return losses[-1]\n",
"\n",
"\n",
"# Iteration in testing process\n",
"def validate(epoch, model, dataloader, criterion,verbose=True):\n",
" model.eval()\n",
@ -750,9 +747,22 @@
}
],
"metadata": {
"orig_nbformat": 4,
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "plaintext"
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,