mindspore

Tensor

mindspore.Tensor

Tensor is a data structure that stores an n-dimensional array.

mindspore.COOTensor

A sparse representation of a set of nonzero elements from a tensor at given indices.

mindspore.CSRTensor

Constructs a sparse tensor in CSR (Compressed Sparse Row) format, with specified values indicated by values and row and column positions indicated by indptr and indices.

mindspore.RowTensor

A sparse representation of a set of tensor slices at given indices.

mindspore.SparseTensor

A sparse representation of a set of nonzero elements from a tensor at given indices.

Parameter

mindspore.Parameter

Parameter is a Tensor subclass, when they are assigned as Cell attributes they are automatically added to the list of its parameters, and will appear, e.g.

mindspore.ParameterTuple

Inherited from tuple, ParameterTuple is used to save multiple parameter.

DataType

class mindspore.dtype

Create a data type object of MindSpore.

The actual path of dtype is /mindspore/common/dtype.py. Run the following command to import the package:

from mindspore import dtype as mstype
  • Numeric Type

    Currently, MindSpore supports Int type, Uint type, Float type and Complex type. The following table lists the details.

    Definition

    Description

    mindspore.int8 , mindspore.byte

    8-bit integer

    mindspore.int16 , mindspore.short

    16-bit integer

    mindspore.int32 , mindspore.intc

    32-bit integer

    mindspore.int64 , mindspore.intp

    64-bit integer

    mindspore.uint8 , mindspore.ubyte

    unsigned 8-bit integer

    mindspore.uint16 , mindspore.ushort

    unsigned 16-bit integer

    mindspore.uint32 , mindspore.uintc

    unsigned 32-bit integer

    mindspore.uint64 , mindspore.uintp

    unsigned 64-bit integer

    mindspore.float16 , mindspore.half

    16-bit floating-point number

    mindspore.float32 , mindspore.single

    32-bit floating-point number

    mindspore.float64 , mindspore.double

    64-bit floating-point number

    mindspore.complex64

    64-bit complex number

    mindspore.complex128

    128-bit complex number

  • Other Type

    For other defined types, see the following table.

    Type

    Description

    tensor

    MindSpore’s tensor type. Data format uses NCHW. For details, see tensor.

    bool_

    Boolean True or False.

    int_

    Integer scalar.

    uint

    Unsigned integer scalar.

    float_

    Floating-point scalar.

    complex

    Complex scalar.

    number

    Number, including int_ , uint , float_ , complex and bool_ .

    list_

    List constructed by tensor , such as List[T0,T1,...,Tn] , where the element Ti can be of different types.

    tuple_

    Tuple constructed by tensor , such as Tuple[T0,T1,...,Tn] , where the element Ti can be of different types.

    function

    Function. Return in two ways, when function is not None, returns Func directly, the other returns Func(args: List[T0,T1,…,Tn], retval: T) when function is None.

    type_type

    Type definition of type.

    type_none

    No matching return type, corresponding to the type(None) in Python.

    symbolic_key

    The value of a variable is used as a key of the variable in env_type .

    env_type

    Used to store the gradient of the free variable of a function, where the key is the symbolic_key of the free variable’s node and the value is the gradient.

  • Tree Topology

    The relationships of the above types are as follows:

    └─────── number
        │   ├─── bool_
        │   ├─── int_
        │   │   ├─── int8, byte
        │   │   ├─── int16, short
        │   │   ├─── int32, intc
        │   │   └─── int64, intp
        │   ├─── uint
        │   │   ├─── uint8, ubyte
        │   │   ├─── uint16, ushort
        │   │   ├─── uint32, uintc
        │   │   └─── uint64, uintp
        │   ├─── float_
        │   │   ├─── float16
        │   │   ├─── float32
        │   │   └─── float64
        │   └─── complex
        │       ├─── complex64
        │       └─── complex128
        ├─── tensor
        │   ├─── Array[Float32]
        │   └─── ...
        ├─── list_
        │   ├─── List[Int32,Float32]
        │   └─── ...
        ├─── tuple_
        │   ├─── Tuple[Int32,Float32]
        │   └─── ...
        ├─── function
        │   ├─── Func
        │   ├─── Func[(Int32, Float32), Int32]
        │   └─── ...
        ├─── type_type
        ├─── type_none
        ├─── symbolic_key
        └─── env_type
    

mindspore.dtype_to_nptype

Convert MindSpore dtype to numpy data type.

mindspore.issubclass_

Determine whether type_ is a subclass of dtype.

mindspore.dtype_to_pytype

Convert MindSpore dtype to python data type.

mindspore.pytype_to_dtype

Convert python type to MindSpore type.

mindspore.get_py_obj_dtype

Get the MindSpore data type, which corresponds to python type or variable.

Seed

mindspore.set_seed

Set global seed.

mindspore.get_seed

Get global seed.

Context

mindspore.set_context

Set context for running environment.

mindspore.get_context

Get context attribute value according to the input key.

mindspore.set_auto_parallel_context

Set auto parallel context, only data parallel supported on CPU.

mindspore.get_auto_parallel_context

Get auto parallel context attribute value according to the key.

mindspore.reset_auto_parallel_context

Reset auto parallel context attributes to the default values:

mindspore.ParallelMode

Parallel mode options.

mindspore.set_ps_context

Set parameter server training mode context.

mindspore.get_ps_context

Get parameter server training mode context attribute value according to the key.

mindspore.reset_ps_context

Reset parameter server training mode context attributes to the default values:

mindspore.set_algo_parameters

Set parameters in the algorithm for parallel strategy searching.

mindspore.get_algo_parameters

Get the algorithm parameter config attributes.

mindspore.reset_algo_parameters

Reset the algorithm parameter attributes.

Model

mindspore.Model

High-Level API for training or inference.

Callback

mindspore.Callback

Abstract base class used to build a Callback class.

mindspore.CheckpointConfig

The configuration of model checkpoint.

mindspore.EarlyStopping

Stop training when a monitored metric has stopped improving.

mindspore.History

Records the network outputs and metrics information into a History object.

mindspore.LambdaCallback

Callback for creating simple, custom callbacks.

mindspore.LearningRateScheduler

Change the learning_rate during training.

mindspore.LossMonitor

Monitor the loss in train or monitor the loss and eval metrics in fit.

mindspore.ModelCheckpoint

The checkpoint callback class.

mindspore.ReduceLROnPlateau

Reduce learning rate when the monitor has stopped improving.

mindspore.RunContext

Hold and manage information about the model.

mindspore.TimeMonitor

Monitor the time in train or eval process.

Dataset Helper

mindspore.DatasetHelper

DatasetHelper is a class to process the MindData dataset and provides the information of dataset.

mindspore.connect_network_with_dataset

Connect the network with dataset in dataset_helper.

mindspore.data_sink

A wrapper function to generate a function for the input function.

Serialization

mindspore.async_ckpt_thread_status

Get the status of asynchronous save checkpoint thread.

mindspore.build_searched_strategy

Build strategy of every parameter in network.

mindspore.convert_model

Convert mindir model to other format model.

mindspore.export

Export the MindSpore network into an offline model in the specified format.

mindspore.load

Load MindIR.

mindspore.load_checkpoint

Load checkpoint info from a specified file.

mindspore.load_distributed_checkpoint

Load checkpoint into net for distributed predication.

mindspore.load_param_into_net

Load parameters into network, return parameter list that are not loaded in the network.

mindspore.merge_sliced_parameter

Merge parameter slices into one parameter.

mindspore.parse_print

Parse data file generated by mindspore.ops.Print.

mindspore.restore_group_info_list

Build rank list, the checkpoint of ranks in the rank list has the same contents with the local rank who saves the group_info_file_name.

mindspore.save_checkpoint

Save checkpoint to a specified file.

JIT

mindspore.JitConfig

Jit config for compile.

mindspore.ms_function

Create a callable MindSpore graph from a Python function.

mindspore.ms_class

Class decorator for user-defined classes.

mindspore.mutable

Make a constant value mutable.

Log

mindspore.get_level

Get the logger level.

mindspore.get_log_config

Get logger configurations.

Installation Verification

mindspore.run_check

Provide a convenient API to check if the installation is successful or failed.

Debugging and Tuning

mindspore.Profiler

This class to enable the profiling of MindSpore neural networks.

mindspore.SummaryCollector

SummaryCollector can help you to collect some common information.

mindspore.SummaryLandscape

SummaryLandscape can help you to collect loss landscape information.

mindspore.SummaryRecord

SummaryRecord is used to record the summary data and lineage data.

mindspore.set_dump

Enable or disable dump for the target and its contents.

Memory Recycle

mindspore.ms_memory_recycle

Recycle memory used by MindSpore.

Thor

mindspore.ConvertModelUtils

Convert model to thor model.

mindspore.ConvertNetUtils

Convert net to thor layer net, used to compute and store second-order information matrix.