Differences with torchtext.datasets.AmazonReviewPolarity

View Source On Gitee

torchtext.datasets.AmazonReviewPolarity

class torchtext.datasets.AmazonReviewPolarity(
    root: str = '.data',
    split: Union[List[str], str] = ('train', 'test'))

For more information, see torchtext.datasets.AmazonReviewPolarity.

mindspore.dataset.AmazonReviewDataset

class mindspore.dataset.AmazonReviewDataset(
    dataset_dir,
    usage=None,
    num_samples=None,
    num_parallel_workers=None,
    shuffle=Shuffle.GLOBAL,
    num_shards=None,
    shard_id=None,
    cache=None)

For more information, see mindspore.dataset.AmazonReviewDataset.

Differences

PyTorch: Read the AmazonReviewPolarity dataset.

MindSpore: Read the AmazonReviewPolarity dataset. Downloading dataset from web is not supported.

Categories

Subcategories

PyTorch

MindSpore

Difference

Parameter

Parameter1

root

dataset_dir

-

Parameter2

split

usage

-

Parameter3

-

num_samples

Specify the number of samples to read from the dataset

Parameter4

-

num_parallel_workers

Specify the number of worker threads to read from the dataset

Parameter5

-

shuffle

Whether to perform shuffle on the dataset

Parameter6

-

num_shards

Number of shards that the dataset will be divided into during the distributed training

Parameter7

-

shard_id

Specify the shard ID to be used for distributed training

Parameter8

-

cache

Specify single node data caching service

Code Example

# PyTorch
import torchtext.datasets as datasets
from torch.utils.data import DataLoader

root = "/path/to/dataset_directory/"
dataset = datasets.AmazonReviewPolarity(root, split=('train', 'test'))
dataloader = DataLoader(dataset)

# MindSpore
import mindspore.dataset as ds

# Download AmazonReviewPolarity dataset files, unzip into the following structure
# .
# └── /path/to/dataset_directory/
#      ├── train.csv
#      ├── test.csv
#      ├── readme.txt
root = "/path/to/dataset_directory/"
ms_dataloader = ds.AmazonReviewDataset(root, usage='all')