|
6 | 6 | "source": [
|
7 | 7 | "# Natural Language Processing with Deep Learning\n",
|
8 | 8 | "\n",
|
9 |
| - "__This is exactly the same notebook as in ../week10_textconv/. Feel free submit the seminar notebook, just make sure you read the assignments at the end.\n", |
| 9 | + "__This is exactly the same notebook as in `../week10_textconv/.`__\n", |
| 10 | + "\n", |
| 11 | + "__Feel free submit the seminar notebook, just make sure you read the assignments at the end.__\n", |
10 | 12 | "\n",
|
11 | 13 | "Today we're gonna apply the newly learned DL tools for sequence processing to the task of predicting job salary.\n",
|
12 | 14 | "\n",
|
|
769 | 771 | " print('\\n\\n')"
|
770 | 772 | ]
|
771 | 773 | },
|
| 774 | + { |
| 775 | + "cell_type": "code", |
| 776 | + "execution_count": null, |
| 777 | + "metadata": { |
| 778 | + "collapsed": true |
| 779 | + }, |
| 780 | + "outputs": [], |
| 781 | + "source": [ |
| 782 | + "print(\"Final eval:\")\n", |
| 783 | + "for batch in iterate_minibatches(data_val, shuffle=False):\n", |
| 784 | + " title_ix = Variable(torch.LongTensor(batch[\"Title\"]), volatile=True)\n", |
| 785 | + " desc_ix = Variable(torch.LongTensor(batch[\"FullDescription\"]), volatile=True)\n", |
| 786 | + " cat_features = Variable(torch.FloatTensor(batch[\"Categorical\"]), volatile=True)\n", |
| 787 | + " reference = Variable(torch.FloatTensor(batch[target_column]), volatile=True)\n", |
| 788 | + "\n", |
| 789 | + " prediction = model(title_ix, desc_ix, cat_features)\n", |
| 790 | + " loss = compute_loss(reference, prediction)\n", |
| 791 | + "\n", |
| 792 | + " val_loss += loss.data.numpy()[0]\n", |
| 793 | + " val_mae += compute_mae(reference, prediction).data.numpy()[0]\n", |
| 794 | + " val_batches += 1\n", |
| 795 | + "\n", |
| 796 | + "print(\"\\tLoss:\\t%.5f\" % (val_loss / val_batches))\n", |
| 797 | + "print(\"\\tMAE:\\t%.5f\" % (val_mae / val_batches))\n", |
| 798 | + "print('\\n\\n')" |
| 799 | + ] |
| 800 | + }, |
772 | 801 | {
|
773 | 802 | "cell_type": "markdown",
|
774 | 803 | "metadata": {},
|
|
0 commit comments