比较与torchtext.datasets.IMDB的差异
torchtext.datasets.IMDB
class torchtext.datasets.IMDB(
    root: str = '.data',
    split: Union[List[str], str] = ('train', 'test'))
更多内容详见torchtext.datasets.IMDB。
mindspore.dataset.IMDBDataset
class mindspore.dataset.IMDBDataset(
    dataset_dir,
    usage=None,
    num_samples=None,
    num_parallel_workers=None,
    shuffle=None,
    sampler=None,
    num_shards=None,
    shard_id=None,
    cache=None)
差异对比
PyTorch:读取IMDB数据集。
MindSpore:读取IMDB数据集,不支持下载。
| 分类 | 子类 | PyTorch | MindSpore | 差异 | 
|---|---|---|---|---|
| 参数 | 参数1 | root | dataset_dir | - | 
| 参数2 | split | usage | - | |
| 参数3 | - | num_samples | 指定从数据集中读取的样本数 | |
| 参数4 | - | num_parallel_workers | 指定读取数据的工作线程数 | |
| 参数5 | - | shuffle | 指定是否混洗数据集 | |
| 参数6 | - | sampler | 指定采样器 | |
| 参数7 | - | num_shards | 指定分布式训练时将数据集进行划分的分片数 | |
| 参数8 | - | shard_id | 指定分布式训练时使用的分片ID号 | |
| 参数9 | - | cache | 指定单节点数据缓存服务 | 
代码示例
# PyTorch
import torchtext.datasets as datasets
from torch.utils.data import DataLoader
root = "/path/to/dataset_directory/"
dataset = datasets.IMDB(root, split=('train', 'test'))
dataloader = DataLoader(dataset)
# MindSpore
import mindspore.dataset as ds
# Download IMDB dataset files, unzip into the following structure
# .
# └── /path/to/dataset_directory/
#      ├── train
#      │    ├── pos
#      │    │    ├── 0_9.txt
#      │    │    ├── 1_7.txt
#      │    │    ├── ...
#      │    ├── neg
#      │    │    ├── 0_3.txt
#      │    │    ├── 1_1.txt
#      │    │    ├── ...
#      ├── test
#      │    ├── pos
#      │    │    ├── 0_10.txt
#      │    │    ├── 1_10.txt
#      │    │    ├── ...
#      │    ├── neg
#      │    │    ├── 0_2.txt
#      │    │    ├── 1_3.txt
#      │    │    ├── ...
root = "/path/to/dataset_directory/"
ms_dataloader = ds.IMDBDataset(root, usage='all')