Function Differences with tf.keras.datasets.imdb

tf.keras.datasets.imdb

class tf.keras.datasets.imdb()

For more information, see tf.keras.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
)

For more information, see mindspore.dataset.IMDBDataset.

Differences

TensorFlow: The IMDB dataset can be downloaded and loaded using the load_data method within this class.

MindSpore: Load the IMDB dataset file from the specified path and return the Dataset.

Code Example

# The following implements IMDBDataset with MindSpore.
import mindspore.dataset as ds

imdb_dataset_dir = "/path/to/imdb_dataset_directory"
dataset = ds.IMDBDataset(dataset_dir=imdb_dataset_dir)

# The following implements imdb with TensorFlow.
import tensorflow as tf

(x_train, y_train), (x_test, y_test) = tf.keras.datasets.imdb.load_data()