{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## NLP Interpret" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [], "source": [ "from fastai.gen_doc.nbdoc import *\n", "from fastai.text import * \n", "from fastai.text.interpret import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[`text.interpret`](/text.interpret.html#text.interpret) is the module that implements custom [`Interpretation`](/train.html#Interpretation) classes for different NLP tasks by inheriting from it." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [], "source": [ "from fastai.gen_doc.nbdoc import *\n", "from fastai.vision import *" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "
class TextClassificationInterpretation[source][test]TextClassificationInterpretation(**`learn`**:[`Learner`](/basic_train.html#Learner), **`preds`**:`Tensor`, **`y_true`**:`Tensor`, **`losses`**:`Tensor`, **`ds_type`**:[`DatasetType`](/basic_data.html#DatasetType)=***`No tests found for TextClassificationInterpretation. To contribute a test please refer to this guide and this discussion.
intrinsic_attention[source][test]intrinsic_attention(**`text`**:`str`, **`class_id`**:`int`=***`None`***)\n",
"\n",
"No tests found for intrinsic_attention. To contribute a test please refer to this guide and this discussion.
html_intrinsic_attention[source][test]html_intrinsic_attention(**`text`**:`str`, **`class_id`**:`int`=***`None`***, **\\*\\*`kwargs`**) → `str`\n",
"\n",
"No tests found for html_intrinsic_attention. To contribute a test please refer to this guide and this discussion.
show_intrinsic_attention[source][test]show_intrinsic_attention(**`text`**:`str`, **`class_id`**:`int`=***`None`***, **\\*\\*`kwargs`**)\n",
"\n",
"No tests found for show_intrinsic_attention. To contribute a test please refer to this guide and this discussion.
show_top_losses[source][test]show_top_losses(**`k`**:`int`, **`max_len`**:`int`=***`70`***)\n",
"\n",
"No tests found for show_top_losses. To contribute a test please refer to this guide and this discussion.
| idx | \n", "text | \n", "
|---|---|
| 0 | \n", "! ! ! xxmaj finally this was directed by the guy who did xxmaj big xxmaj xxunk ? xxmaj must be a replay of xxmaj jonestown - hollywood style . xxmaj xxunk ! xxbos xxmaj this is a extremely well - made film . xxmaj the acting , script and camera - work are all first - rate . xxmaj the music is good , too , though it is | \n", "
| 1 | \n", ") . xxmaj all in all , we were very disappointed at this xxmaj spike xxmaj lee effort ! ! xxbos a really great movie and true story . xxmaj dan xxmaj jansen the xxmaj greatest xxunk ever . a touching and beautiful movie the whole family can enjoy . xxmaj the story of xxmaj jane xxmaj xxunk battle with cancer and xxmaj dan xxmaj jansen love for his sister | \n", "
| 2 | \n", "just typical folks ) in everyday settings in order to create xxunk involving and realistic films . \\n \\n xxmaj in this case , the film is about xxmaj french and xxmaj german coal miners , so appropriately , the people in the roles seem like miners -- not actors . xxmaj the central conflict as the film begins is that there is a huge mine xxunk on the | \n", "
| 3 | \n", "here that xxunk banning ... which is a shame because i never would have sat through it where it not for the fact that it 's on ' the xxunk list ' . xxmaj the plot actually gives the film a decent base - or at least more of a decent base than most xxunk films - and it follows an actress who is kidnapped and dragged off into the | \n", "
| 4 | \n", "xxmaj at the same time , the xxmaj john xxmaj holmes character shows a very clever hustler who is able to pass through the xxunk and xxunk situations almost xxunk . xxmaj the movie deserves being watched more than once . xxmaj the seventies ambiance xxunk and full of drugs is amazing . xxbos xxmaj if you loved xxmaj long xxmaj way xxmaj round you will enjoy this nearly as | \n", "
| epoch | \n", "train_loss | \n", "valid_loss | \n", "accuracy | \n", "time | \n", "
|---|---|---|---|---|
| 0 | \n", "4.650112 | \n", "3.822781 | \n", "0.290729 | \n", "00:21 | \n", "
| 1 | \n", "4.378561 | \n", "3.766616 | \n", "0.295357 | \n", "00:21 | \n", "
| epoch | \n", "train_loss | \n", "valid_loss | \n", "accuracy | \n", "time | \n", "
|---|---|---|---|---|
| 0 | \n", "0.666474 | \n", "0.666000 | \n", "0.605000 | \n", "00:16 | \n", "
| 1 | \n", "0.666053 | \n", "0.646565 | \n", "0.615000 | \n", "00:18 | \n", "