TensorFlow and MindSpore

View Source On Gitee

Mapping between TensorFlow APIs and MindSpore APIs, which is provided by the community. There may be differences in parameters, inputs, outputs, logic functions, and specific scenarios. For details, see the description of each API or the difference comparison provided.

More MindSpore developers are also welcome to participate in improving the mapping content.

tf

TensorFlow 1.15 APIs

MindSpore APIs

Description

tf.expand_dims

mindspore.ops.ExpandDims

tf.eye

mindspore.ops.Eye

tf.fill

mindspore.ops.Fill

tf.gather

mindspore.ops.Gather

tf.gradients

mindspore.ops.GradOperation

diff

tf.norm

mindspore.nn.Norm

tf.one_hot

mindspore.nn.OneHot

tf.ones_like

mindspore.ops.OnesLike

tf.pad

mindspore.nn.Pad

tf.print

mindspore.ops.Print

tf.reshape

mindspore.ops.Reshape

tf.shape

mindspore.ops.Shape

tf.size

mindspore.ops.Size

tf.slice

mindspore.ops.Slice

tf.stop_gradient

mindspore.ops.stop_gradient

tf.Tensor

mindspore.Tensor

tf.tile

mindspore.ops.Tile

tf.transpose

mindspore.ops.Transpose

tf.zeros_like

mindspore.ops.ZerosLike

tf.data

Many data processing operations in MindSpore are shared by each dataset class. The following uses ImageFolderDataset and CSVDataset as examples to compare the API differences, and other dataset classes are the same.

TensorFlow 1.15 APIs

MindSpore APIs

Description

tf.data.Dataset.apply

mindspore.dataset.GeneratorDataset.apply

tf.data.Dataset.batch

mindspore.dataset.GeneratorDataset.batch

tf.data.Dataset.concatenate

mindspore.dataset.GeneratorDataset.concat

tf.data.Dataset.filter

mindspore.dataset.GeneratorDataset.filter

tf.data.Dataset.flat_map

mindspore.dataset.GeneratorDataset.flat_map

tf.data.Dataset.from_generator

mindspore.dataset.GeneratorDataset

diff

tf.data.Dataset.from_tensor_slices

mindspore.dataset.NumpySlicesDataset

diff

tf.data.Dataset.map

mindspore.dataset.GeneratorDataset.map

tf.data.Dataset.prefetch

mindspore.dataset.config.set_prefetch_size

diff

tf.data.Dataset.repeat

mindspore.dataset.GeneratorDataset.repeat

tf.data.Dataset.shuffle

mindspore.dataset.GeneratorDataset.shuffle

diff

tf.data.Dataset.skip

mindspore.dataset.GeneratorDataset.skip

tf.data.Dataset.take

mindspore.dataset.GeneratorDataset.take

tf.data.Dataset.zip

mindspore.dataset.GeneratorDataset.zip

tf.data.TextLineDataset

mindspore.dataset.TextFileDataset

diff

tf.data.TFRecordDataset

mindspore.dataset.TFRecordDataset

diff

tf.data.experimental.bucket_by_sequence_length

mindspore.dataset.GeneratorDataset.bucket_batch_by_length

diff

tf.data.experimental.CsvDataset

mindspore.dataset.CSVDataset

diff

tf.distribute

TensorFlow 1.15 APIs

MindSpore APIs

Description

tf.distribute.Strategy

set_auto_parallel_context(parallel_mode=ParallelMode.DATA_PARALLEL)

diff

tf.image

TensorFlow 1.15 APIs

MindSpore APIs

Description

tf.image.ssim

mindspore.nn.SSIM

tf.image.central_crop

mindspore.dataset.vision.CenterCrop

diff

tf.image.convert_image_dtype

mindspore.dataset.transforms.TypeCast

diff

tf.image.crop_to_bounding_box

mindspore.dataset.vision.Crop

diff

tf.image.flip_left_right

mindspore.dataset.vision.HorizontalFlip

tf.image.flip_up_down

mindspore.dataset.vision.VerticalFlip

tf.image.grayscale_to_rgb

mindspore.dataset.vision.ConvertColor

diff

tf.image.hsv_to_rgb

mindspore.dataset.vision.HsvToRgb

tf.image.pad_to_bounding_box

mindspore.dataset.vision.Pad

diff

tf.image.per_image_standardization

mindspore.dataset.vision.Normalize

diff

tf.image.random_crop

mindspore.dataset.vision.RandomCrop

diff

tf.image.random_flip_left_right

mindspore.dataset.vision.RandomHorizontalFlip

diff

tf.image.random_flip_up_down

mindspore.dataset.vision.RandomVerticalFlip

diff

tf.image.ResizeMethod

mindspore.dataset.vision.Inter

tf.image.resize_images

mindspore.dataset.vision.Resize

diff

tf.image.rgb_to_grayscale

mindspore.dataset.vision.ConvertColor

diff

tf.image.rot90

mindspore.dataset.vision.Rotate

diff

tf.io

TensorFlow 1.15 APIs

MindSpore APIs

Description

tf.io.decode_image

mindspore.dataset.vision.Decode

diff

tf.keras

TensorFlow 1.15 APIs

MindSpore APIs

Description

tf.keras.backend.batch_dot

mindspore.ops.batch_dot

tf.keras.backend.dot

mindspore.ops.dot

tf.keras.datasets.cifar10

mindspore.dataset.Cifar10Dataset

diff

tf.keras.datasets.cifar100

mindspore.dataset.Cifar100Dataset

diff

tf.keras.datasets.fashion_mnist

mindspore.dataset.FashionMnistDataset

diff

tf.keras.datasets.imdb

mindspore.dataset.IMDBDataset

diff

tf.keras.datasets.mnist

mindspore.dataset.MnistDataset

diff

tf.keras.layers.Embedding

mindspore.nn.Embedding

tf.keras.layers.Flatten

mindspore.nn.Flatten

tf.keras.layers.LayerNormalization

mindspore.nn.LayerNorm

tf.keras.layers.LSTM

mindspore.nn.LSTM

tf.keras.layers.PReLU

mindspore.nn.PReLU

tf.keras.layers.RNN

mindspore.ops.DynamicRNN

tf.keras.optimizers.Adagrad

mindspore.nn.Adagrad

diff

tf.keras.optimizers.Adam

mindspore.nn.Adam

diff

tf.keras.optimizers.SGD

mindspore.nn.SGD

diff

tf.keras.preprocessing.image.random_rotation

mindspore.dataset.vision.RandomRotation

diff

tf.keras.preprocessing.image.random_shear

mindspore.dataset.vision.RandomAffine

diff

tf.keras.preprocessing.image.random_shift

mindspore.dataset.vision.RandomAffine

diff

tf.layers

TensorFlow 1.15 APIs

MindSpore APIs

Description

tf.layers.Dense

mindspore.nn.Dense

tf.linalg

TensorFlow 1.15 APIs

MindSpore APIs

Description

tf.linalg.matmul

mindspore.nn.MatMul

tf.math

TensorFlow 1.15 APIs

MindSpore APIs

Description

tf.math.add

mindspore.ops.Add

tf.math.add_n

mindspore.ops.AddN

tf.math.divide

mindspore.ops.Div

tf.math.erf

mindspore.ops.Erf

tf.math.greater

mindspore.ops.Greater

tf.math.less_equal

mindspore.ops.LessEqual

tf.math.log

mindspore.ops.Log

tf.math.multiply

mindspore.ops.Mul

tf.math.pow

mindspore.ops.Pow

tf.math.sigmoid

mindspore.nn.Sigmoid

tf.math.subtract

mindspore.ops.Sub

tf.metrics

TensorFlow 1.15 APIs

MindSpore APIs

Description

tf.metrics.mean_iou

mindspore.ops.IOU

tf.nn

TensorFlow 1.15 APIs

MindSpore APIs

Description

tf.nn.avg_pool2d

mindspore.nn.AvgPool2d

tf.nn.batch_normalization

mindspore.ops.BatchNorm

tf.nn.bias_add

mindspore.ops.BiasAdd

tf.nn.conv2d

mindspore.nn.Conv2d

tf.nn.conv2d_transpose

mindspore.nn.Conv2dTranspose

tf.nn.ctc_loss

mindspore.ops.CTCLoss

tf.nn.dropout

mindspore.nn.Dropout

tf.nn.elu

mindspore.nn.ELU

tf.nn.l2_loss

mindspore.ops.L2Loss

tf.nn.l2_normalize

mindspore.ops.L2Normalize

tf.nn.leaky_relu

mindspore.nn.LeakyReLU

tf.nn.max_pool_with_argmax

mindspore.ops.MaxPoolWithArgmax

tf.nn.max_pool2d

mindspore.nn.MaxPool2d

tf.nn.moments

mindspore.nn.Moments

tf.nn.relu

mindspore.nn.ReLU

tf.nn.selu

mindspore.ops.SeLU

tf.nn.sigmoid_cross_entropy_with_logits

mindspore.ops.SigmoidCrossEntropyWithLogits

tf.nn.softmax

mindspore.nn.Softmax

tf.nn.softmax_cross_entropy_with_logits

mindspore.nn.SoftmaxCrossEntropyWithLogits

diff

tf.random

TensorFlow 1.15 APIs

MindSpore APIs

Description

tf.random.gamma

mindspore.ops.Gamma

tf.random.uniform

mindspore.ops.uniform

tf.sparse

TensorFlow 1.15 APIs

MindSpore APIs

Description

tf.sparse.SparseTensor

mindspore.SparseTensor

tf.train

TensorFlow 1.15 APIs

MindSpore APIs

Description

tf.train.exponential_decay

mindspore.nn.ExponentialDecayLR

tf.train.linear_cosine_decay

mindspore.nn.CosineDecayLR

diff

tf.train.MomentumOptimizer

mindspore.nn.Momentum

diff

tfp

TensorFlow Probability 0.14.1 APIs

MindSpore APIs

Description

tfp.bijectors.Softplus

mindspore.nn.probability.bijector.Softplus

diff