Browse Source

修改tutorial

tags/v0.4.10
zide05 5 years ago
parent
commit
78af3491a4
2 changed files with 9 additions and 3 deletions
  1. +5
    -2
      docs/source/tutorials/tutorial_4_loss_optimizer.rst
  2. +4
    -1
      docs/source/tutorials/tutorial_5_datasetiter.rst

+ 5
- 2
docs/source/tutorials/tutorial_4_loss_optimizer.rst View File

@@ -1,4 +1,4 @@
==============================================================================
==============================================================================
动手实现一个文本分类器I-使用Trainer和Tester快速训练和测试
==============================================================================

@@ -19,7 +19,9 @@

loader = SSTLoader()
#这里的all.txt是下载好数据后train.txt、dev.txt、test.txt的组合
dataset = loader.load("./trainDevTestTrees_PTB/trees/all.txt")
#loader.load(path)会首先判断path是否为none,若是则自动从网站下载数据,若不是则读入数据并返回databundle
databundle_ = loader.load("./trainDevTestTrees_PTB/trees/all.txt")
dataset = databundle_.datasets['train']
print(dataset[0])

输出数据如下::
@@ -31,6 +33,7 @@

数据处理
可以使用事先定义的 :class:`~fastNLP.io.SSTPipe` 类对数据进行基本预处理,这里我们手动进行处理。
我们使用 :class:`~fastNLP.DataSet` 类的 :meth:`~fastNLP.DataSet.apply` 方法将 ``target`` :mod:`~fastNLP.core.field` 转化为整数。
.. code-block:: python


+ 4
- 1
docs/source/tutorials/tutorial_5_datasetiter.rst View File

@@ -20,7 +20,9 @@

loader = SSTLoader()
#这里的all.txt是下载好数据后train.txt、dev.txt、test.txt的组合
dataset = loader.load("./trainDevTestTrees_PTB/trees/all.txt")
#loader.load(path)会首先判断path是否为none,若是则自动从网站下载数据,若不是则读入数据并返回databundle
databundle_ = loader.load("./trainDevTestTrees_PTB/trees/all.txt")
dataset = databundle_.datasets['train']
print(dataset[0])

输出数据如下::
@@ -32,6 +34,7 @@

数据处理
可以使用事先定义的 :class:`~fastNLP.io.SSTPipe` 类对数据进行基本预处理,这里我们手动进行处理。
我们使用 :class:`~fastNLP.DataSet` 类的 :meth:`~fastNLP.DataSet.apply` 方法将 ``target`` :mod:`~fastNLP.core.field` 转化为整数。
.. code-block:: python


Loading…
Cancel
Save