TensorFlow and MindSpore API Mapping Table

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.

TensorFlow 2.6

tf

TensorFlow 2.6 APIs

MindSpore APIs

Descriptions

tf.bitwise.invert

mindspore.ops.invert

Consistent

tf.clip_by_value

mindspore.ops.clip_by_value

diff

tf.expand_dims

mindspore.ops.expand_dims

diff

tf.eye

mindspore.ops.eye

diff

tf.fill

mindspore.ops.fill

diff

[tf.range

mindspore.ops.range

The functions are consistent, but the parameter names are inconsistent.

tf.random.uniform_candidate_sampler

mindspore.ops.uniform_candidate_sampler

diff

tf.raw_ops.ApplyGradientDescent

mindspore.ops.ApplyGradientDescent

Consistent

tf.raw_ops.ApproximateEqual

mindspore.ops.approximate_equal

Consistent

tf.raw_ops.DataFormatDimMap

mindspore.ops.DataFormatDimMap

The functions are consistent, but the parameter names are inconsistent.

tf.raw_ops.InplaceUpdate

mindspore.ops.inplace_update

The functions are consistent, but the parameter names are inconsistent.

tf.raw_ops.Inv

mindspore.ops.inv

Consistent

tf.raw_ops.LRN

mindspore.ops.LRN

diff

tf.raw_ops.MatrixDiagPartV3

mindspore.ops.matrix_diag_part

The functions are consistent, but the parameter names are inconsistent.

tf.raw_ops.MatrixDiagV3

mindspore.ops.matrix_diag

The functions are consistent, but the parameter names are inconsistent.

tf.raw_ops.MatrixSetDiagV3

mindspore.ops.matrix_set_diag

The functions are consistent, but the parameter names are inconsistent.

tf.raw_ops.MatrixSolve

mindspore.ops.matrix_solve

Consistent

tf.raw_ops.RandomGamma

mindspore.ops.random_gamma

Consistent

tf.raw_ops.ScatterNdMax

mindspore.ops.scatter_nd_max

The functions are consistent, but the parameter names are inconsistent.

tf.raw_ops.ScatterNdMin

mindspore.ops.scatter_nd_min

The functions are consistent, but the parameter names are inconsistent.

tf.raw_ops.Select

mindspore.ops.select

The functions are consistent, but the parameter names are inconsistent.

tf.raw_ops.SparseApplyAdagradV2

mindspore.ops.SparseApplyAdagradV2

diff

tf.raw_ops.SparseToDense

mindspore.ops.SparseToDense

diff

tf.raw_ops.TensorScatterAdd

mindspore.ops.tensor_scatter_add

The functions are consistent, but the parameter names are inconsistent.

tf.raw_ops.TensorScatterSub

mindspore.ops.tensor_scatter_sub

The functions are consistent, but the parameter names are inconsistent.

tf.reverse_sequence

mindspore.ops.reverse_sequence

The functions are consistent, but the parameter names are inconsistent.

tf.scatter_nd

mindspore.ops.scatter_nd

Consistent

tf.space_to_batch_nd

mindspore.ops.space_to_batch_nd

The functions are consistent, but the parameter names are inconsistent.

tf.unstack

mindspore.ops.unstack

The functions are consistent, but the parameter names are inconsistent.

tf.compat.v1

TensorFlow 2.6 APIs

MindSpore APIs

Descriptions

tf.compat.v1.assign_sub

mindspore.ops.assign_sub

diff

tf.compat.v1.layers.Dense

mindspore.nn.Dense

diff

tf.compat.v1.random_poisson

mindspore.ops.random_poisson

The functions are consistent, but the parameter names are inconsistent.

tf.compat.v1.scatter_div

mindspore.ops.scatter_div

The functions are consistent, but the parameter names are inconsistent.

tf.compat.v1.scatter_max

mindspore.ops.scatter_max

The functions are consistent, but the parameter names are inconsistent.

tf.compat.v1.scatter_min

mindspore.ops.scatter_min

The functions are consistent, but the parameter names are inconsistent.

tf.compat.v1.scatter_mul

mindspore.ops.scatter_mul

diff

tf.compat.v1.scatter_nd_add

mindspore.ops.scatter_nd_add

The functions are consistent, but the parameter names are inconsistent.

tf.compat.v1.scatter_nd_sub

mindspore.ops.scatter_nd_sub

The functions are consistent, but the parameter names are inconsistent.

tf.compat.v1.scatter_update

mindspore.ops.scatter_update

The functions are consistent, but the parameter names are inconsistent.

tf.compat.v1.sparse_segment_mean

mindspore.ops.sparse_segment_mean

The functions are consistent, but the parameter names are inconsistent.

tf.compat.v1.train.MomentumOptimizer

mindspore.nn.Momentum

diff

tf.compat.v1.train.ProximalAdagradOptimizer

mindspore.nn.ProximalAdagrad

diff

tf.compat.v1.train.RMSPropOptimizer

mindspore.nn.RMSProp

diff

tf.compat.v1.train.exponential_decay

mindspore.nn.exponential_decay_lr

diff

tf.compat.v1.train.cosine_decay

mindspore.nn.CosineDecayLR

diff

tf.concat

mindspore.ops.concat

The functions are consistent, but the parameter names are inconsistent.

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 2.6 APIs

MindSpore APIs

Descriptions

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.math

TensorFlow 2.6 APIs

MindSpore APIs

Descriptions

tf.math.argmax

mindspore.ops.argmax

diff

tf.math.argmin

mindspore.ops.argmin

diff

tf.math.add

mindspore.ops.add

diff

tf.math.bessel_i0

mindspore.ops.bessel_i0

Consistent

tf.math.bessel_i0e

mindspore.ops.bessel_i0e

Consistent

tf.math.bessel_i1

mindspore.ops.bessel_i1

Consistent

tf.math.bessel_i1e

mindspore.ops.bessel_i1e

Consistent

tf.math.cumsum

mindspore.ops.cumsum

diff

tf.math.divide

mindspore.ops.div

diff

tf.math.erf

mindspore.ops.erf

diff

tf.math.in_top_k

mindspore.ops.intopk

The functions are consistent, but the parameter names are inconsistent.

tf.math.special.bessel_j0

mindspore.ops.bessel_j0

Consistent

tf.math.special.bessel_j1

mindspore.ops.bessel_j1

Consistent

tf.math.special.bessel_k0

mindspore.ops.bessel_k0

Consistent

tf.math.special.bessel_k0e

mindspore.ops.bessel_k0e

Consistent

tf.math.special.bessel_k1

mindspore.ops.bessel_k1

Consistent

tf.math.special.bessel_k1e

mindspore.ops.bessel_k1e

Consistent

tf.math.special.bessel_y0

mindspore.ops.bessel_y0

Consistent

tf.math.special.bessel_y1

mindspore.ops.bessel_y1

Consistent

tf.math.unsorted_segment_max

mindspore.ops.unsorted_segment_max

The functions are consistent, but the parameter names are inconsistent.

tf.math.unsorted_segment_min

mindspore.ops.unsorted_segment_min

The functions are consistent, but the parameter names are inconsistent.

tf.math.unsorted_segment_prod

mindspore.ops.unsorted_segment_prod

The functions are consistent, but the parameter names are inconsistent.

tf.math.unsorted_segment_sum

mindspore.ops.unsorted_segment_sum

The functions are consistent, but the parameter names are inconsistent.

tf.math.xdivy

mindspore.ops.xdivy

Consistent

tf.image

TensorFlow 2.6 APIs

MindSpore APIs

Descriptions

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

mindspore.dataset.vision.Resize

diff

tf.image.rgb_to_grayscale

mindspore.dataset.vision.ConvertColor

diff

tf.image.rot90

mindspore.dataset.vision.Rotate

diff

tf.keras

TensorFlow 2.6 APIs

MindSpore APIs

Descriptions

tf.keras.layers.BatchNormalization

mindspore.nn.BatchNorm2d

diff

tf.keras.layers.LayerNormalization

mindspore.nn.LayerNorm

diff

tf.keras.layers.LSTM

mindspore.nn.LSTM

diff

tf.keras.layers.PReLU

mindspore.nn.PReLU

diff

tf.keras.optimizers.Adagrad

mindspore.nn.Adagrad

diff

tf.keras.optimizers.Adam

mindspore.nn.Adam

diff

tf.keras.optimizers.Ftrl

mindspore.nn.FTRL

diff

tf.keras.optimizers.SGD

mindspore.nn.SGD

diff

tf.one_hot

mindspore.ops.one_hot

Consistent

tf.nn

TensorFlow 2.6 APIs

MindSpore APIs

Descriptions

tf.nn.avg_pool2d

mindspore.nn.AvgPool2d

diff

tf.nn.bias_add

mindspore.ops.bias_add

diff

tf.nn.conv2d

mindspore.nn.Conv2d

diff

tf.nn.conv2d_transpose

mindspore.nn.Conv2dTranspose

diff

tf.nn.ctc_loss

mindspore.ops.CTCLoss

diff

tf.nn.ctc_greedy_decoder

mindspore.ops.ctc_greedy_decoder

diff

tf.nn.dropout

mindspore.ops.dropout

diff

tf.nn.elu

mindspore.ops.elu

diff

tf.nn.leaky_relu

mindspore.nn.LeakyReLU

diff

tf.nn.max_pool2d

mindspore.nn.MaxPool2d

diff

tf.nn.relu

mindspore.nn.ReLU

diff

tf.nn.softmax

mindspore.nn.Softmax

diff

tf.nn.softmax_cross_entropy_with_logits

mindspore.nn.SoftmaxCrossEntropyWithLogits

diff

TensorFlow 1.15

tf

TensorFlow 1.15 APIs

MindSpore APIs

Descriptions

tf.gather

mindspore.ops.Gather

tf.gradients

mindspore.grad

diff

tf.ones_like

mindspore.ops.OnesLike

tf.pad

mindspore.nn.Pad

tf.print

mindspore.ops.Print

tf.repeat

mindspore.Tensor.repeat

tf.reshape

mindspore.ops.Reshape

tf.reshape

mindspore.Tensor.reshape

tf.shape

mindspore.ops.Shape

tf.size

mindspore.ops.Size

tf.slice

mindspore.ops.Slice

tf.squeeze

mindspore.Tensor.squeeze

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.arg_max

mindspore.Tensor.argmax

diff

tf.arg_min

mindspore.Tensor.argmin

diff

tf.clip_by_value

mindspore.Tensor.clip

diff

tf.io

TensorFlow 1.15 APIs

MindSpore APIs

Descriptions

tf.io.decode_image

mindspore.dataset.vision.Decode

diff

tf.keras

TensorFlow 1.15 APIs

MindSpore APIs

Descriptions

tf.keras.Model

mindspore.train.Model

diff

tf.keras.Model.fit
tf.keras.Model.fit_generator

mindspore.train.Model.train

diff

tf.keras.Model.predict
tf.keras.Model.predict_generator

mindspore.train.Model.eval

diff

tf.keras.backend.batch_dot

mindspore.ops.batch_dot

diff

tf.keras.backend.dot

mindspore.ops.dot

diff

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.initializers.Constant

mindspore.common.initializer.Constant

diff

tf.keras.initializers.Ones

mindspore.common.initializer.One

tf.keras.initializers.RandomNormal

mindspore.common.initializer.Normal

diff

tf.keras.initializers.RandomUniform

mindspore.common.initializer.Uniform

diff

tf.keras.initializers.TruncatedNormal

mindspore.common.initializer.TruncatedNormal

diff

tf.keras.initializers.VarianceScaling

mindspore.common.initializer.XavierUniform

diff

tf.keras.initializers.Zeros

mindspore.common.initializer.Zero

tf.keras.layers.Embedding

mindspore.nn.Embedding

tf.keras.layers.Flatten

mindspore.nn.Flatten

tf.keras.layers.RNN

mindspore.ops.DynamicRNN

tf.keras.metrics.Accuracy
tf.keras.metrics.BinaryAccuracy
tf.keras.metrics.CategoricalAccuracy
tf.keras.metrics.SparseCategoricalAccuracy

mindspore.train.Accuracy

diff

tf.keras.metrics.AUC

mindspore.train.auc

diff

tf.keras.metrics.CosineSimilarity

mindspore.train.CosineSimilarity

diff

tf.keras.metrics.Mean

mindspore.train.Loss

tf.keras.metrics.MeanAbsoluteError

mindspore.train.MAE

tf.keras.metrics.MeanSquaredError

mindspore.train.MSE

tf.keras.metrics.Precision

mindspore.train.Precision

diff

tf.keras.metrics.Recall

mindspore.train.Recall

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.linalg

TensorFlow 1.15 APIs

MindSpore APIs

Descriptions

tf.linalg.matmul

mindspore.ops.MatMul

tf.math

TensorFlow 1.15 APIs

MindSpore APIs

Descriptions

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.reduce_std

mindspore.Tensor.std

diff

tf.math.reduce_sum

mindspore.Tensor.sum

diff

tf.math.reduce_variance

mindspore.Tensor.var

diff

tf.math.sigmoid

mindspore.nn.Sigmoid

tf.math.subtract

mindspore.ops.Sub

tf.metrics

TensorFlow 1.15 APIs

MindSpore APIs

Descriptions

tf.metrics.mean_iou

mindspore.ops.IOU

tf.nn

TensorFlow 1.15 APIs

MindSpore APIs

Descriptions

tf.nn.batch_normalization

mindspore.ops.BatchNorm

tf.nn.l2_loss

mindspore.ops.L2Loss

tf.nn.l2_normalize

mindspore.ops.L2Normalize

tf.nn.max_pool_with_argmax

mindspore.ops.MaxPoolWithArgmax

tf.nn.selu

mindspore.ops.SeLU

tf.nn.sigmoid_cross_entropy_with_logits

mindspore.ops.SigmoidCrossEntropyWithLogits

tf.random

TensorFlow 1.15 APIs

MindSpore APIs

Descriptions

tf.random.gamma

mindspore.ops.Gamma

tf.random.uniform

mindspore.ops.uniform

tf.sparse

TensorFlow 1.15 APIs

MindSpore APIs

Descriptions

tf.sparse.SparseTensor

mindspore.SparseTensor

tfp

TensorFlow Probability 0.14.1 APIs

MindSpore APIs

Descriptions

tfp.bijectors.Softplus

mindspore.nn.probability.bijector.Softplus

diff