| @@ -66,7 +66,7 @@ class QuantDtype(enum.Enum): | |||
| @staticmethod | |||
| def switch_signed(dtype): | |||
| """ | |||
| Swicth the signed state of the input quant datatype. | |||
| Switch the signed state of the input quant datatype. | |||
| Args: | |||
| dtype (QuantDtype): quant datatype. | |||
| @@ -43,10 +43,10 @@ def create_quant_config(quant_observer=(nn.FakeQuantWithMinMaxObserver, nn.FakeQ | |||
| symmetric=(False, False), | |||
| narrow_range=(False, False)): | |||
| r""" | |||
| Configs the oberser type of weights and data flow with quant params. | |||
| Configs the observer type of weights and data flow with quant params. | |||
| Args: | |||
| quant_observer (Observer, list or tuple): The oberser type to do quantization. The first element represent | |||
| quant_observer (Observer, list or tuple): The observer type to do quantization. The first element represent | |||
| weights and second element represent data flow. | |||
| Default: (nn.FakeQuantWithMinMaxObserver, nn.FakeQuantWithMinMaxObserver) | |||
| quant_delay (int, list or tuple): Number of steps after which weights and activations are quantized during | |||
| @@ -64,7 +64,7 @@ def create_quant_config(quant_observer=(nn.FakeQuantWithMinMaxObserver, nn.FakeQ | |||
| The first element represents weights and the second element represents data flow. Default: (False, False) | |||
| Returns: | |||
| QuantConfig, Contains the oberser type of weight and activation. | |||
| QuantConfig, Contains the observer type of weight and activation. | |||
| """ | |||
| weight_observer = quant_observer[0].partial_init(quant_delay=quant_delay[0], quant_dtype=quant_dtype[0], | |||
| per_channel=per_channel[0], symmetric=symmetric[0], | |||
| @@ -273,7 +273,7 @@ def load_nonquant_param_into_quant_net(quant_model, params_dict, quant_new_param | |||
| Args: | |||
| quant_model: quantization model. | |||
| params_dict: parameter dict that stores fp32 parameters. | |||
| quant_new_params: parameters that exist in quantative network but not in unquantative network. | |||
| quant_new_params: parameters that exist in quantitative network but not in unquantitative network. | |||
| Returns: | |||
| None | |||
| @@ -452,7 +452,7 @@ def reset_auto_parallel_context(): | |||
| def _check_target_specific_cfgs(device, arg_key): | |||
| """Checking whether a config is sutable for a specified device""" | |||
| """Checking whether a config is suitable for a specified device""" | |||
| device_cfgs = { | |||
| 'enable_auto_mixed_precision': ['Ascend'], | |||
| 'enable_dump': ['Ascend'], | |||
| @@ -545,7 +545,7 @@ def set_context(**kwargs): | |||
| - op_trace: collect single operator performance data. | |||
| The profiling can choose the combination of `training_trace`, `task_trace`, | |||
| `training_trace` and `task_trace` combination, and eparated by colons; | |||
| `training_trace` and `task_trace` combination, and separated by colons; | |||
| a single operator can choose `op_trace`, `op_trace` cannot be combined with | |||
| `training_trace` and `task_trace`. Default: "training_trace". | |||
| check_bprop (bool): Whether to check bprop. Default: False. | |||
| @@ -567,7 +567,7 @@ class Pad(Cell): | |||
| - If `mode` is "CONSTANT", it fills the edge with 0, regardless of the values of the `input_x`. | |||
| If the `input_x` is [[1,2,3], [4,5,6], [7,8,9]] and `paddings` is [[1,1], [2,2]], then the | |||
| Outputs is [[0,0,0,0,0,0,0], [0,0,1,2,3,0,0], [0,0,4,5,6,0,0], [0,0,7,8,9,0,0], [0,0,0,0,0,0,0]]. | |||
| - If `mode` is "REFLECT", it uses a way of symmetrical copying throught the axis of symmetry to fill in. | |||
| - If `mode` is "REFLECT", it uses a way of symmetrical copying through the axis of symmetry to fill in. | |||
| If the `input_x` is [[1,2,3], [4,5,6], [7,8,9]] and `paddings` is [[1,1], [2,2]], then the | |||
| Outputs is [[6,5,4,5,6,5,4], [3,2,1,2,3,2,1], [6,5,4,5,6,5,4], [9,8,7,8,9,8,7], [6,5,4,5,6,5,4]]. | |||
| - If `mode` is "SYMMETRIC", the filling method is similar to the "REFLECT". It is also copied | |||
| @@ -99,7 +99,7 @@ class LSTM(Cell): | |||
| Data type of `hx` must be the same as `input`. | |||
| Outputs: | |||
| Tuple, a tuple constains (`output`, (`h_n`, `c_n`)). | |||
| Tuple, a tuple contains (`output`, (`h_n`, `c_n`)). | |||
| - **output** (Tensor) - Tensor of shape (seq_len, batch_size, num_directions * `hidden_size`). | |||
| - **hx_n** (tuple) - A tuple of two Tensor (h_n, c_n) both of shape | |||
| @@ -162,7 +162,7 @@ class Range(Cell): | |||
| class LGamma(Cell): | |||
| r""" | |||
| Calculates LGamma using Lanczos' approximation refering to "A Precision Approximationof the Gamma Function". | |||
| Calculates LGamma using Lanczos' approximation referring to "A Precision Approximation of the Gamma Function". | |||
| The algorithm is: | |||
| .. math:: | |||
| @@ -288,7 +288,7 @@ class LGamma(Cell): | |||
| class DiGamma(Cell): | |||
| r""" | |||
| Calculates Digamma using Lanczos' approximation refering to "A Precision Approximationof the Gamma Function". | |||
| Calculates Digamma using Lanczos' approximation referring to "A Precision Approximation of the Gamma Function". | |||
| The algorithm is: | |||
| .. math:: | |||
| @@ -252,7 +252,7 @@ class BatchNorm1d(_BatchNorm): | |||
| Note: | |||
| The implementation of BatchNorm is different in graph mode and pynative mode, therefore the mode is not | |||
| recommended to be changed after net was initilized. | |||
| recommended to be changed after net was initialized. | |||
| Args: | |||
| num_features (int): `C` from an expected input of size (N, C). | |||
| @@ -339,7 +339,7 @@ class BatchNorm2d(_BatchNorm): | |||
| Note: | |||
| The implementation of BatchNorm is different in graph mode and pynative mode, therefore that mode can not be | |||
| changed after net was initilized. | |||
| changed after net was initialized. | |||
| Note that the formula for updating the running_mean and running_var is | |||
| :math:`\hat{x}_\text{new} = (1 - \text{momentum}) \times x_t + \text{momentum} \times \hat{x}`, | |||
| where :math:`\hat{x}` is the estimated statistic and :math:`x_t` is the new observed value. | |||
| @@ -111,7 +111,7 @@ def _partial_init(cls_or_self, **kwargs): | |||
| This can be useful when there is a need to create classes with the same | |||
| constructor arguments, but different instances. | |||
| Example:: | |||
| Example: | |||
| >>> Foo.partial_init = classmethod(_partial_init) | |||
| >>> foo_builder = Foo.partial_init(a=3, b=4).partial_init(answer=42) | |||
| >>> foo_instance1 = foo_builder() | |||
| @@ -57,7 +57,7 @@ class Metric(metaclass=ABCMeta): | |||
| data (numpy.array): Input data. | |||
| Returns: | |||
| bool, return trun, if input data are one-hot encoding. | |||
| bool, return true, if input data are one-hot encoding. | |||
| """ | |||
| if data.ndim > 1 and np.equal(data ** 2, data).all(): | |||
| shp = (data.shape[0],) + data.shape[2:] | |||
| @@ -260,7 +260,7 @@ class Optimizer(Cell): | |||
| return gradients | |||
| def _grad_sparse_indices_deduplicate(self, gradients): | |||
| """ In the case of using big operators, de duplicate the 'indexes' in gradients.""" | |||
| """ In the case of using big operators, deduplicate the 'indexes' in gradients.""" | |||
| if self._target != 'CPU' and self._unique: | |||
| gradients = self.map_(F.partial(_indices_deduplicate), gradients) | |||
| return gradients | |||
| @@ -78,7 +78,7 @@ class RMSProp(Optimizer): | |||
| :math:`m_{t}` is moment, the delta of `w`, :math:`m_{t-1}` is the last moment of :math:`m_{t}`. | |||
| :math:`\\rho` represents `decay`. :math:`\\beta` is the momentum term, represents `momentum`. | |||
| :math:`\\epsilon` is a smoothing term to avoid division by zero, represents `epsilon`. | |||
| :math:`\\eta` is learning rate, represents `learning_rate`. :math:`\\nabla Q_{i}(w)` is gradientse, | |||
| :math:`\\eta` is learning rate, represents `learning_rate`. :math:`\\nabla Q_{i}(w)` is gradients, | |||
| represents `gradients`. | |||
| Note: | |||
| @@ -253,7 +253,7 @@ class Bijector(Cell): | |||
| If args[0] is a distribution instance, the call will generate a new distribution derived from | |||
| the input distribution. | |||
| Otherwise, input[0] must be the name of a Bijector function, e.g. "forward", then this call will | |||
| go in the construct and invoke the correstpoding Bijector function. | |||
| go in the construct and invoke the corresponding Bijector function. | |||
| Args: | |||
| *args: args[0] shall be either a distribution or the name of a Bijector function. | |||
| @@ -12,14 +12,14 @@ | |||
| # See the License for the specific language governing permissions and | |||
| # limitations under the License. | |||
| # ============================================================================ | |||
| """Utitly functions to help distribution class.""" | |||
| """Utility functions to help distribution class.""" | |||
| import numpy as np | |||
| from mindspore.ops import operations as P | |||
| from mindspore.common import dtype as mstype | |||
| def exp_generic(input_x): | |||
| """ | |||
| Log op on Ascend doesn't supprot int types. | |||
| Log op on Ascend doesn't support int types. | |||
| Fix this with casting the type. | |||
| """ | |||
| exp = P.Exp() | |||
| @@ -36,7 +36,7 @@ def log_generic(input_x): | |||
| """ | |||
| Log op on Ascend is calculated as log(abs(x)). | |||
| Fix this with putting negative values as nan. | |||
| And log op on Ascend doesn't supprot int types. | |||
| And log op on Ascend doesn't support int types. | |||
| Fix this with casting the type. | |||
| """ | |||
| log = P.Log() | |||
| @@ -12,7 +12,7 @@ | |||
| # See the License for the specific language governing permissions and | |||
| # limitations under the License. | |||
| # ============================================================================ | |||
| """Utitly functions to help distribution class.""" | |||
| """Utility functions to help distribution class.""" | |||
| import numpy as np | |||
| from mindspore import context | |||
| from mindspore._checkparam import Validator as validator | |||
| @@ -52,7 +52,7 @@ class Beta(Distribution): | |||
| >>> from mindspore import Tensor | |||
| >>> # To initialize a Beta distribution of the concentration1 3.0 and the concentration0 4.0. | |||
| >>> b1 = msd.Beta([3.0], [4.0], dtype=mindspore.float32) | |||
| >>> # A Beta distribution can be initilized without arguments. | |||
| >>> # A Beta distribution can be initialized without arguments. | |||
| >>> # In this case, `concentration1` and `concentration0` must be passed in through arguments. | |||
| >>> b2 = msd.Beta(dtype=mindspore.float32) | |||
| >>> # Here are some tensors used below for testing | |||
| @@ -52,7 +52,7 @@ class Gamma(Distribution): | |||
| >>> from mindspore import Tensor | |||
| >>> # To initialize a Gamma distribution of the concentration 3.0 and the rate 4.0. | |||
| >>> g1 = msd.Gamma([3.0], [4.0], dtype=mindspore.float32) | |||
| >>> # A Gamma distribution can be initilized without arguments. | |||
| >>> # A Gamma distribution can be initialized without arguments. | |||
| >>> # In this case, `concentration` and `rate` must be passed in through arguments. | |||
| >>> g2 = msd.Gamma(dtype=mindspore.float32) | |||
| >>> # Here are some tensors used below for testing | |||
| @@ -26,8 +26,8 @@ from ._utils.custom_ops import exp_generic, log_generic | |||
| class Geometric(Distribution): | |||
| """ | |||
| Geometric Distribution. | |||
| It represents that there are k failures before the first sucess, namely taht there are in total k+1 Bernoulli trails | |||
| when the first success is achieved. | |||
| It represents that there are k failures before the first success, namely that there are in total k+1 Bernoulli | |||
| trails when the first success is achieved. | |||
| Args: | |||
| probs (float, list, numpy.ndarray, Tensor): The probability of success. | |||
| @@ -235,7 +235,7 @@ class LogNormal(msd.TransformedDistribution): | |||
| def _var(self, loc=None, scale=None): | |||
| """ | |||
| The varience of the distribution. | |||
| The variance of the distribution. | |||
| """ | |||
| mean, sd = self._check_param_type(loc, scale) | |||
| var = self.distribution("var", mean=mean, sd=sd) | |||
| @@ -48,7 +48,7 @@ class Poisson(Distribution): | |||
| >>> from mindspore import Tensor | |||
| >>> # To initialize an Poisson distribution of the rate 0.5. | |||
| >>> p1 = msd.Poisson([0.5], dtype=mindspore.float32) | |||
| >>> # An Poisson distribution can be initilized without arguments. | |||
| >>> # An Poisson distribution can be initialized without arguments. | |||
| >>> # In this case, `rate` must be passed in through `args` during function calls. | |||
| >>> p2 = msd.Poisson(dtype=mindspore.float32) | |||
| >>> | |||
| @@ -33,7 +33,7 @@ class TransformedDistribution(Distribution): | |||
| bijector (Bijector): The transformation to perform. | |||
| distribution (Distribution): The original distribution. Must has a float dtype. | |||
| seed (int): The seed is used in sampling. The global seed is used if it is None. Default:None. | |||
| If this seed is given when a TransformedDistribution object is initialised, the object's sampling function | |||
| If this seed is given when a TransformedDistribution object is initialized, the object's sampling function | |||
| will use this seed; elsewise, the underlying distribution's seed will be used. | |||
| name (str): The name of the transformed distribution. Default: 'transformed_distribution'. | |||
| @@ -242,7 +242,7 @@ class Uniform(Distribution): | |||
| def _cross_entropy(self, dist, low_b, high_b, low=None, high=None): | |||
| """ | |||
| Evaluate cross entropy between Uniform distributoins. | |||
| Evaluate cross entropy between Uniform distributions. | |||
| Args: | |||
| dist (str): The type of the distributions. Should be "Uniform" in this case. | |||
| @@ -33,7 +33,7 @@ def _div_scalar(x, y): | |||
| Args: | |||
| x (Number): x | |||
| y (NUmber): y | |||
| y (Number): y | |||
| Returns: | |||
| Number, equal to x / y, the type is same as x. | |||
| @@ -48,7 +48,7 @@ def _equal_scalar(x, y): | |||
| Args: | |||
| x (Number): first input number. | |||
| y (NUmber): second input number. | |||
| y (Number): second input number. | |||
| Returns: | |||
| bool, if x == y return true, x != y return false. | |||
| @@ -194,7 +194,7 @@ def _tensor_getitem_by_slice(data, slice_index): | |||
| @getitem.register("Tensor", "Tensor") | |||
| def _tensor_getitem_by_tensor(data, tensor_index): | |||
| """ | |||
| Getting item of tensor by tensor indice. | |||
| Getting item of tensor by tensor indices. | |||
| Inputs: | |||
| data (Tensor): A tensor. | |||
| @@ -62,7 +62,7 @@ def _scalar_mul_tensor(x, y): | |||
| @mul.register("Tensor", "Number") | |||
| def _tensor_mul_scalar(x, y): | |||
| """ | |||
| Returns x * y where x is a tensor and y is a scalar. x and y hava same dtype. | |||
| Returns x * y where x is a tensor and y is a scalar. x and y have same dtype. | |||
| Outputs: | |||
| Tensor, has the same dtype as x. | |||
| @@ -33,7 +33,7 @@ def _not_equal_scalar(x, y): | |||
| Args: | |||
| x (Number): x | |||
| y (NUmber): y | |||
| y (Number): y | |||
| Returns: | |||
| bool, if x != y return true, x == y return false. | |||
| @@ -123,7 +123,7 @@ def _none_not_equal_scalar(x, y): | |||
| Args: | |||
| x: None. | |||
| y: NUmber. | |||
| y: Number. | |||
| Returns: | |||
| bool, return True. | |||
| @@ -28,7 +28,7 @@ def _list_setitem_with_string(data, number_index, value): | |||
| Assigns value to list. | |||
| Inputs: | |||
| data (list): Data of type lis. | |||
| data (list): Data of type list. | |||
| number_index (Number): Index of data. | |||
| Outputs: | |||
| @@ -43,7 +43,7 @@ def _list_setitem_with_number(data, number_index, value): | |||
| Assigns value to list. | |||
| Inputs: | |||
| data (list): Data of type lis. | |||
| data (list): Data of type list. | |||
| number_index (Number): Index of data. | |||
| value (Number): Value given. | |||
| @@ -59,7 +59,7 @@ def _list_setitem_with_Tensor(data, number_index, value): | |||
| Assigns value to list. | |||
| Inputs: | |||
| data (list): Data of type lis. | |||
| data (list): Data of type list. | |||
| number_index (Number): Index of data. | |||
| value (Tensor): Value given. | |||
| @@ -75,7 +75,7 @@ def _list_setitem_with_List(data, number_index, value): | |||
| Assigns value to list. | |||
| Inputs: | |||
| data (list): Data of type lis. | |||
| data (list): Data of type list. | |||
| number_index (Number): Index of data. | |||
| value (list): Value given. | |||
| @@ -91,7 +91,7 @@ def _list_setitem_with_Tuple(data, number_index, value): | |||
| Assigns value to list. | |||
| Inputs: | |||
| data (list): Data of type lis. | |||
| data (list): Data of type list. | |||
| number_index (Number): Index of data. | |||
| value (list): Value given. | |||
| @@ -79,7 +79,7 @@ def laplace(shape, mean, lambda_param, seed=None): | |||
| shape (tuple): The shape of random tensor to be generated. | |||
| mean (Tensor): The mean μ distribution parameter, which specifies the location of the peak. | |||
| With float32 data type. | |||
| lambda_param (Tensor): The parameter used for controling the variance of this random distribution. The | |||
| lambda_param (Tensor): The parameter used for controlling the variance of this random distribution. The | |||
| variance of Laplace distribution is equal to twice the square of lambda_param. With float32 data type. | |||
| seed (int): Seed is used as entropy source for Random number engines generating pseudo-random numbers. | |||
| Default: None, which will be treated as 0. | |||
| @@ -937,7 +937,7 @@ class Split(PrimitiveWithCheck): | |||
| Args: | |||
| axis (int): Index of the split position. Default: 0. | |||
| output_num (int): The number of output tensors. Must be postive int. Default: 1. | |||
| output_num (int): The number of output tensors. Must be positive int. Default: 1. | |||
| Raises: | |||
| ValueError: If `axis` is out of the range [-len(`input_x.shape`), len(`input_x.shape`)), | |||
| @@ -1464,7 +1464,7 @@ class InvertPermutation(PrimitiveWithInfer): | |||
| - **input_x** (Union(tuple[int], list[int]) - The input is constructed by multiple | |||
| integers, i.e., :math:`(y_1, y_2, ..., y_S)` representing the indices. | |||
| The values must include 0. There can be no duplicate values or negative values. | |||
| Only constant value is allowed. The maximum value msut be equal to length of input_x. | |||
| Only constant value is allowed. The maximum value must be equal to length of input_x. | |||
| Outputs: | |||
| tuple[int]. It has the same length as the input. | |||
| @@ -1925,7 +1925,7 @@ class UnsortedSegmentMin(PrimitiveWithCheck): | |||
| The data type must be float16, float32 or int32. | |||
| - **segment_ids** (Tensor) - A `1-D` tensor whose shape is :math:`(x_1)`, the value must be >= 0. | |||
| The data type must be int32. | |||
| - **num_segments** (int) - The value spcifies the number of distinct `segment_ids`. | |||
| - **num_segments** (int) - The value specifies the number of distinct `segment_ids`. | |||
| Note: | |||
| If the segment_id i is absent in the segment_ids, then output[i] will be filled with | |||
| @@ -1981,7 +1981,7 @@ class UnsortedSegmentMax(PrimitiveWithCheck): | |||
| The data type must be float16, float32 or int32. | |||
| - **segment_ids** (Tensor) - A `1-D` tensor whose shape is :math:`(x_1)`, the value must be >= 0. | |||
| The data type must be int32. | |||
| - **num_segments** (int) - The value spcifies the number of distinct `segment_ids`. | |||
| - **num_segments** (int) - The value specifies the number of distinct `segment_ids`. | |||
| Note: | |||
| If the segment_id i is absent in the segment_ids, then output[i] will be filled with | |||
| @@ -2038,7 +2038,7 @@ class UnsortedSegmentProd(PrimitiveWithInfer): | |||
| With float16, float32 or int32 data type. | |||
| - **segment_ids** (Tensor) - A `1-D` tensor whose shape is :math:`(x_1)`, the value must be >= 0. | |||
| Data type must be int32. | |||
| - **num_segments** (int) - The value spcifies the number of distinct `segment_ids`, | |||
| - **num_segments** (int) - The value specifies the number of distinct `segment_ids`, | |||
| must be greater than 0. | |||
| Outputs: | |||
| @@ -2503,7 +2503,7 @@ class Select(PrimitiveWithInfer): | |||
| If neither is None, :math:`x` and :math:`y` must have the same shape. If :math:`x` and :math:`y` are | |||
| scalars, the conditional tensor must be a scalar. If :math:`x` and :math:`y` are | |||
| higher-demensional vectors, the `condition` must be a vector whose size matches the | |||
| higher-dimensional vectors, the `condition` must be a vector whose size matches the | |||
| first dimension of :math:`x`, or must have the same shape as :math:`y`. | |||
| The conditional tensor acts as an optional compensation (mask), which | |||
| @@ -2511,7 +2511,7 @@ class Select(PrimitiveWithInfer): | |||
| selected from :math:`x` (if true) or :math:`y` (if false) based on the value of each | |||
| element. | |||
| If condition is a vector, then :math:`x` and :math:`y` are higher-demensional matrices, then it | |||
| If condition is a vector, then :math:`x` and :math:`y` are higher-dimensional matrices, then it | |||
| chooses to copy that row (external dimensions) from :math:`x` and :math:`y`. If condition has | |||
| the same shape as :math:`x` and :math:`y`, you can choose to copy these elements from :math:`x` | |||
| and :math:`y`. | |||
| @@ -3904,7 +3904,7 @@ class SpaceToBatchND(PrimitiveWithInfer): | |||
| Args: | |||
| block_shape (Union[list(int), tuple(int)]): The block shape of dividing block with all value greater than 1. | |||
| The length of `block_shape` is M correspoding to the number of spatial dimensions. M must be 2. | |||
| The length of `block_shape` is M corresponding to the number of spatial dimensions. M must be 2. | |||
| paddings (Union[tuple, list]): The padding values for H and W dimension, containing 2 subtraction list. | |||
| Each contains 2 integer value. All values must be greater than 0. | |||
| `paddings[i]` specifies the paddings for the spatial dimension i, | |||
| @@ -4003,7 +4003,7 @@ class BatchToSpaceND(PrimitiveWithInfer): | |||
| Args: | |||
| block_shape (Union[list(int), tuple(int)]): The block shape of dividing block with all value >= 1. | |||
| The length of block_shape is M correspoding to the number of spatial dimensions. M must be 2. | |||
| The length of block_shape is M corresponding to the number of spatial dimensions. M must be 2. | |||
| crops (Union[list(int), tuple(int)]): The crop value for H and W dimension, containing 2 subtraction list, | |||
| each containing 2 int value. | |||
| All values must be >= 0. crops[i] specifies the crop values for spatial dimension i, which corresponds to | |||
| @@ -4106,7 +4106,7 @@ class BroadcastTo(PrimitiveWithInfer): | |||
| Raises: | |||
| ValueError: Given a shape tuple, if it has several -1; or if the -1 is in an invalid position | |||
| such as one that does not have a opposing dimension in an input tensor; or if the target and | |||
| input shapes are incompatiable. | |||
| input shapes are incompatible. | |||
| Args: | |||
| shape (tuple): The target shape to broadcast. Can be fully specified, or have -1 in one position | |||
| @@ -1305,7 +1305,7 @@ class SquaredDifference(_MathBinaryOp): | |||
| - **input_x** (Union[Tensor, Number, bool]) - The first input is a number, or a bool, | |||
| or a tensor whose data type is float16, float32, int32 or bool. | |||
| - **input_y** (Union[Tensor, Number, bool]) - The second input is a number, or a bool when the first input | |||
| is a tensor or a tensor whose data type isfloat16, float32, int32 or bool. | |||
| is a tensor or a tensor whose data type is float16, float32, int32 or bool. | |||
| Outputs: | |||
| Tensor, the shape is the same as the one after broadcasting, | |||
| @@ -3137,6 +3137,8 @@ class NPUGetFloatStatus(PrimitiveWithInfer): | |||
| >>> get_status = ops.NPUGetFloatStatus() | |||
| >>> init = alloc_status() | |||
| >>> get_status(init) | |||
| Tensor(shape=[8], dtype=Float32, value= [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, | |||
| 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00]) | |||
| >>> print(init) | |||
| [1. 1. 1. 1. 1. 1. 1. 1.] | |||
| """ | |||
| @@ -3184,6 +3186,8 @@ class NPUClearFloatStatus(PrimitiveWithInfer): | |||
| >>> init = alloc_status() | |||
| >>> flag = get_status(init) | |||
| >>> clear_status(init) | |||
| Tensor(shape=[8], dtype=Float32, value= [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, | |||
| 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00]) | |||
| >>> print(init) | |||
| [1. 1. 1. 1. 1. 1. 1. 1.] | |||
| """ | |||
| @@ -1894,7 +1894,8 @@ class TopK(PrimitiveWithInfer): | |||
| >>> k = 3 | |||
| >>> values, indices = topk(input_x, k) | |||
| >>> print((values, indices)) | |||
| ([5.0, 4.0, 3.0], [4, 3, 2]) | |||
| (Tensor(shape=[3], dtype=Float16, value= [ 5.0000e+00, 4.0000e+00, 3.0000e+00]), Tensor(shape=[3], | |||
| dtype=Int32, value= [4, 3, 2])) | |||
| """ | |||
| @prim_attr_register | |||
| @@ -2038,7 +2039,7 @@ class ApplyMomentum(PrimitiveWithInfer): | |||
| Data type conversion of Parameter is not supported. RuntimeError exception will be thrown. | |||
| Args: | |||
| use_locking (bool): Whether to enable a lock to protect the variable and accumlation tensors | |||
| use_locking (bool): Whether to enable a lock to protect the variable and accumulation tensors | |||
| from being updated. Default: False. | |||
| use_nesterov (bool): Enable Nesterov momentum. Default: False. | |||
| gradient_scale (float): The scale of the gradient. Default: 1.0. | |||
| @@ -2334,7 +2335,7 @@ class SGD(PrimitiveWithCheck): | |||
| >>> stat = Tensor(np.array([1.5, -0.3, 0.2, -0.7]), mindspore.float32) | |||
| >>> output = sgd(parameters, gradient, learning_rate, accum, momentum, stat) | |||
| >>> print(output[0]) | |||
| [ 1.9899 -0.4903 1.6952001 3.9801 ] | |||
| (Tensor(shape=[4], dtype=Float32, value= [ 1.98989999e+00, -4.90300000e-01, 1.69520009e+00, 3.98009992e+00]),) | |||
| """ | |||
| @prim_attr_register | |||
| @@ -5774,7 +5775,7 @@ class ApplyFtrl(PrimitiveWithInfer): | |||
| There is only one output for GPU environment. | |||
| - **var** (Tensor) - This value is alwalys zero and the input parameters has been updated in-place. | |||
| - **var** (Tensor) - This value is always zero and the input parameters has been updated in-place. | |||
| Supported Platforms: | |||
| ``Ascend`` ``GPU`` | |||
| @@ -5817,7 +5818,7 @@ class ApplyFtrl(PrimitiveWithInfer): | |||
| [ 1.43758726e+00, 9.89177322e+00]]), Tensor(shape=[2, 2], dtype=Float32, value= | |||
| [[-1.86994812e+03, -1.64906018e+03], | |||
| [-3.22187836e+02, -1.20163989e+03]])) | |||
| >>> else: | |||
| ... else: | |||
| ... print(net.var.asnumpy()) | |||
| [[0.4614181 0.5309642 ] | |||
| [0.2687151 0.38206503]] | |||
| @@ -567,7 +567,7 @@ class PopulationCount(PrimitiveWithInfer): | |||
| - **input** (Tensor) - The data type must be int16 or uint16. | |||
| Outputs: | |||
| Tensor, with the sam shape as the input. | |||
| Tensor, with the same shape as the input. | |||
| Supported Platforms: | |||
| ``Ascend`` | |||
| @@ -513,11 +513,11 @@ def export(net, *inputs, file_name, file_format='AIR', **kwargs): | |||
| file_name (str): File name of the model to be exported. | |||
| file_format (str): MindSpore currently supports 'AIR', 'ONNX' and 'MINDIR' format for exported model. | |||
| - AIR: Ascend Intermidiate Representation. An intermidiate representation format of Ascend model. | |||
| - AIR: Ascend Intermediate Representation. An intermediate representation format of Ascend model. | |||
| Recommended suffix for output file is '.air'. | |||
| - ONNX: Open Neural Network eXchange. An open format built to represent machine learning models. | |||
| Recommended suffix for output file is '.onnx'. | |||
| - MINDIR: MindSpore Native Intermidiate Representation for Anf. An intermidiate representation format | |||
| - MINDIR: MindSpore Native Intermediate Representation for Anf. An intermediate representation format | |||
| for MindSpore models. | |||
| Recommended suffix for output file is '.mindir'. | |||