Differences with torchtext.datasets.IWSLT2017
torchtext.datasets.IWSLT2017
class torchtext.datasets.IWSLT2017(
root: str = '.data',
split: Union[List[str], str] = ('train', 'valid', 'test'),
language_pair: Sequence = ('de', 'en'))
For more information, see torchtext.datasets.IWSLT2017.
mindspore.dataset.IWSLT2017Dataset
class mindspore.dataset.IWSLT2017Dataset(
dataset_dir,
usage=None,
language_pair=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.IWSLT2017Dataset.
Differences
PyTorch: Read the IWSLT2017 dataset.
MindSpore: Read the IWSLT2017 dataset. Download dataset from web is not supported.
Categories |
Subcategories |
PyTorch |
MindSpore |
Difference |
---|---|---|---|---|
Parameter |
Parameter1 |
root |
dataset_dir |
- |
Parameter2 |
split |
usage |
- |
|
Parameter3 |
language_pair |
language_pair |
- |
|
Parameter4 |
- |
num_samples |
The number of images to be included in the dataset |
|
Parameter5 |
- |
num_parallel_workers |
Number of worker threads to read the data |
|
Parameter6 |
- |
shuffle |
Whether to perform shuffle on the dataset |
|
Parameter7 |
- |
num_shards |
Number of shards that the dataset will be divided into |
|
Parameter8 |
- |
shard_id |
The shard ID within num_shards |
|
Parameter9 |
- |
cache |
Use tensor caching service to speed up dataset processing |
Code Example
# PyTorch
import torchtext.datasets as datasets
root = "/path/to/dataset_root/"
train_iter, valid_iter, test_iter = datasets.IWSLT2017(root, split=('train', 'valid', 'test'))
data = next(iter(train_iter))
# MindSpore
import mindspore.dataset as ds
# Download IWSLT2017 dataset files, unzip into the following structure
# .
# └── /path/to/dataset_directory/
# └── DeEnItNlRo
# └── DeEnItNlRo
# └── DeEnItNlRo-DeEnItNlRo
# ├── IWSLT17.TED.dev2010.de-en.de.xml
# ├── train.tags.de-en.de
# ├── ...
root = "/path/to/dataset_directory/"
dataset = ds.IWSLT2017Dataset(root, usage='all')
data = next(iter(dataset))