Browse Source

tutorial_for_developer initial

tags/v0.3.0
yh 5 years ago
parent
commit
490555af20
1 changed files with 56 additions and 151 deletions
  1. +56
    -151
      tutorials/fastnlp_1_minute_tutorial.ipynb

+ 56
- 151
tutorials/fastnlp_1_minute_tutorial.ipynb View File

@@ -19,16 +19,52 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 50,
"execution_count": 3,
"metadata": {}, "metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/yh/miniconda2/envs/python3/lib/python3.6/site-packages/tqdm/autonotebook/__init__.py:14: TqdmExperimentalWarning: Using `tqdm.autonotebook.tqdm` in notebook mode. Use `tqdm.tqdm` instead to force console mode (e.g. in jupyter console)\n",
" \" (e.g. in jupyter console)\", TqdmExperimentalWarning)\n"
]
}
],
"source": [ "source": [
"import sys\n",
"sys.path.append(\"../\")\n",
"\n",
"from fastNLP import DataSet\n", "from fastNLP import DataSet\n",
"\n",
"# linux_path = \"../test/data_for_tests/tutorial_sample_dataset.csv\"\n", "# linux_path = \"../test/data_for_tests/tutorial_sample_dataset.csv\"\n",
"win_path = \"C:\\\\Users\\zyfeng\\Desktop\\FudanNLP\\\\fastNLP\\\\test\\\\data_for_tests\\\\tutorial_sample_dataset.csv\"\n",
"win_path = \"../test/data_for_tests/tutorial_sample_dataset.csv\"\n",
"ds = DataSet.read_csv(win_path, headers=('raw_sentence', 'label'), sep='\\t')" "ds = DataSet.read_csv(win_path, headers=('raw_sentence', 'label'), sep='\\t')"
] ]
}, },
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'raw_sentence': this quiet , introspective and entertaining independent is worth seeking .,\n",
"'label': 4,\n",
"'label_seq': 4,\n",
"'words': ['this', 'quiet', ',', 'introspective', 'and', 'entertaining', 'independent', 'is', 'worth', 'seeking', '.']}"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ds[1]"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
@@ -42,7 +78,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 52,
"execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@@ -58,65 +94,15 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 60,
"metadata": {
"collapsed": false
},
"execution_count": 5,
"metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Train size: "
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" "
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"54"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Test size: "
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" "
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"23"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
"Train size: 54\n",
"Test size: 23\n"
] ]
} }
], ],
@@ -129,7 +115,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 61,
"execution_count": 6,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@@ -177,14 +163,7 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"training epochs started 2018-12-07 14:03:41"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
"training epochs started 2018-12-07 14:03:41\n"
] ]
}, },
{ {
@@ -201,84 +180,10 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"\r"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Epoch 1/3. Step:2/6. AccuracyMetric: acc=0.26087"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\r"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Epoch 2/3. Step:4/6. AccuracyMetric: acc=0.347826"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\r"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Epoch 3/3. Step:6/6. AccuracyMetric: acc=0.608696"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\r"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Train finished!"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
"Epoch 1/3. Step:2/6. AccuracyMetric: acc=0.26087\n",
"Epoch 2/3. Step:4/6. AccuracyMetric: acc=0.347826\n",
"Epoch 3/3. Step:6/6. AccuracyMetric: acc=0.608696\n",
"Train finished!\n"
] ]
} }
], ],
@@ -311,23 +216,23 @@
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 2",
"display_name": "Python 3",
"language": "python", "language": "python",
"name": "python2"
"name": "python3"
}, },
"language_info": { "language_info": {
"codemirror_mode": { "codemirror_mode": {
"name": "ipython", "name": "ipython",
"version": 2
"version": 3
}, },
"file_extension": ".py", "file_extension": ".py",
"mimetype": "text/x-python", "mimetype": "text/x-python",
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
"pygments_lexer": "ipython3",
"version": "3.6.7"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
} }

Loading…
Cancel
Save