mindspore.Tensor

class mindspore.Tensor[source]

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

Note

  • If init interface is used to initialize Tensor, the Tensor.init_data API needs to be called to load the actual data to Tensor.

  • All modes of CPU and GPU, and Atlas training series with graph mode (mode=mindspore.GRAPH_MODE) do not supported in-place operations yet.

Warning

To convert dtype of a Tensor, it is recommended to use Tensor.astype() rather than Tensor(sourceTensor, dtype=newDtype).

Parameters
  • input_data (Union[Tensor, float, int, bool, tuple, list, numpy.ndarray]) – The data to be stored. It can be another Tensor, Python number or NumPy ndarray. Default: None .

  • dtype (mindspore.dtype) – Used to indicate the data type of the output Tensor. The argument should be defined in mindspore.dtype. If it is None , the data type of the output Tensor will be the same as the input_data. Default: None .

  • shape (Union[tuple, list, int, mindspore.Symbol]) – Used to indicate the shape of the output Tensor. If input_data is available, shape doesn't need to be set. If None or Symbol exists in shape , a tensor of dynamic shape is created, input_data doesn't need to be set; if only integers exist in shape, a tensor of static shape is created, input_data or init must be set. Default: None .

  • init (Initializer) – The information of init data. init is used for delayed initialization in parallel mode, when using init, dtype and shape must be set. Default: None .

  • const_arg (bool) – Whether the tensor is a constant when it is used for the argument of a network. Default: False .

  • device (str) – This parameter is reserved and does not need to be configured. Default: None .

Outputs:

Tensor.

Note

The default value None of input_data works as a placeholder, it does not mean that we can create a NoneType Tensor. Tensor with shape contains 0 is not fully tested and supported.

Examples

>>> import numpy as np
>>> import mindspore as ms
>>> from mindspore import Tensor
>>> from mindspore.common.initializer import One
>>> # initialize a tensor with numpy.ndarray
>>> t1 = Tensor(np.zeros([1, 2, 3]), ms.float32)
>>> print(t1)
[[[0. 0. 0.]
[0. 0. 0.]]]
>>> print(type(t1))
<class 'mindspore.common.tensor.Tensor'>
>>> print(t1.shape)
(1, 2, 3)
>>> print(t1.dtype)
Float32
>>>
>>> # initialize a tensor with a float scalar
>>> t2 = Tensor(0.1)
>>> print(t2)
0.1
>>> print(type(t2))
<class 'mindspore.common.tensor.Tensor'>
>>> print(t2.shape)
()
>>> print(t2.dtype)
Float32
>>>
>>> # initialize a tensor with a tuple
>>> t3 = Tensor((1, 2))
>>> print(t3)
[1 2]
>>> print(type(t3))
<class 'mindspore.common.tensor.Tensor'>
>>> print(t3.shape)
(2,)
>>> print(t3.dtype)
Int64
...
>>> # initialize a tensor with init
>>> t4 = Tensor(shape = (1, 3), dtype=ms.float32, init=One())
>>> print(t4)
[[1. 1. 1.]]
>>> print(type(t4))
<class 'mindspore.common.tensor.Tensor'>
>>> print(t4.shape)
(1, 3)
>>> print(t4.dtype)
Float32

mindspore.Tensor.abs

Returns absolute value of a tensor element-wise.

mindspore.Tensor.absolute

Alias for Tensor.abs().

mindspore.Tensor.acos

Computes arccosine of self element-wise.

mindspore.Tensor.acosh

Computes inverse hyperbolic cosine of self element-wise.

mindspore.Tensor.add_

In-place version of mindspore.Tensor.add().

mindspore.Tensor.add

Adds other value to self element-wise.

mindspore.Tensor.addbmm

For details, please refer to mindspore.ops.addbmm().

mindspore.Tensor.addcdiv

For details, please refer to mindspore.ops.addcdiv().

mindspore.Tensor.addcmul

For details, please refer to mindspore.ops.addcmul().

mindspore.Tensor.addmm

For details, please refer to mindspore.ops.addmm().

mindspore.Tensor.addmm_

In-place version of mindspore.Tensor.addmm().

mindspore.Tensor.addmv

Performs a matrix-vector product of mat and vec, and add self to the final result.

mindspore.Tensor.addr

For details, please refer to mindspore.ops.addr().

mindspore.Tensor.adjoint

For details, please refer to mindspore.ops.adjoint().

mindspore.Tensor.all

Reduces a dimension of self by the "logical AND" of all elements in the dimension, by default.

mindspore.Tensor.allclose

Returns a new Tensor with boolean elements representing if each element of self is "close" to the corresponding element of other.

mindspore.Tensor.amax

For details, please refer to mindspore.ops.amax().

mindspore.Tensor.amin

For details, please refer to mindspore.ops.amin().

mindspore.Tensor.aminmax

For details, please refer to mindspore.ops.aminmax().

mindspore.Tensor.any

Reduces a dimension of self by the "logical OR" of all elements in the dimension, by default.

mindspore.Tensor.angle

For details, please refer to mindspore.ops.angle().

mindspore.Tensor.approximate_equal

For details, please refer to mindspore.ops.approximate_equal(), The parameter other of current interface is the same as the parameter y of the reference interface.

mindspore.Tensor.arccos

Alias for mindspore.Tensor.acos().

mindspore.Tensor.arccosh

Alias for mindspore.Tensor.acosh().

mindspore.Tensor.arcsin

Alias for mindspore.Tensor.asin().

mindspore.Tensor.arcsinh

Alias for mindspore.Tensor.asinh().

mindspore.Tensor.arctan

Alias for mindspore.Tensor.atan().

mindspore.Tensor.arctan2

Alias for Tensor.atan2().

mindspore.Tensor.arctanh

Alias for mindspore.Tensor.atanh().

mindspore.Tensor.argmax

Return the indices of the maximum values of self across a dimension.

mindspore.Tensor.argmax_with_value

Compute the max value of input Tensor on the specified axis, and return the max value and index.

mindspore.Tensor.argmin

Returns the indices of the minimum value of self across the axis.

mindspore.Tensor.argmin_with_value

Compute the max value of input Tensor on the specified axis, return the minimum value and index.

mindspore.Tensor.argsort

Sorts self along the given dimension in specified order and return the sorted indices.

mindspore.Tensor.argwhere

For details, please refer to mindspore.ops.argwhere().

mindspore.Tensor.asin

Computes arcsine of self element-wise.

mindspore.Tensor.asinh

Computes inverse hyperbolic sine of self element-wise.

mindspore.Tensor.asnumpy

Convert tensor to numpy array.

mindspore.Tensor.assign_value

Assign another tensor value to this tensor.

mindspore.Tensor.astype

Return a copy of the tensor, cast to a specified type.

mindspore.Tensor.atan

Computes the trigonometric inverse tangent of self element-wise.

mindspore.Tensor.atan2

Returns arctangent of self/other element-wise.

mindspore.Tensor.atanh

Computes inverse hyperbolic tangent of self element-wise.

mindspore.Tensor.baddbmm

The result is the sum of the self and a batch matrix-matrix product of matrices in batch1 and batch2.

mindspore.Tensor.bernoulli

For details, please refer to mindspore.mint.bernoulli().

mindspore.Tensor.bfloat16

Converts input tensor dtype to bfloat16.

mindspore.Tensor.bincount

Count the occurrences of each value in the self.

mindspore.Tensor.bitwise_and

Returns bitwise and of two tensors element-wise.

mindspore.Tensor.bitwise_not

Returns bitwise not of self.

mindspore.Tensor.bitwise_left_shift

For details, please refer to mindspore.ops.bitwise_left_shift().

mindspore.Tensor.bitwise_or

Returns bitwise or of two tensors element-wise.

mindspore.Tensor.bitwise_right_shift

For details, please refer to mindspore.ops.bitwise_right_shift().

mindspore.Tensor.bitwise_xor

Returns bitwise xor of two tensors element-wise.

mindspore.Tensor.bmm

For details, please refer to mindspore.ops.bmm().

mindspore.Tensor.bool

Converts input tensor dtype to bool.

mindspore.Tensor.broadcast_to

For details, please refer to mindspore.ops.broadcast_to().

mindspore.Tensor.byte

Converts input tensor dtype to uint8.

mindspore.Tensor.cauchy

Fills the tensor with numbers drawn from the Cauchy distribution.

mindspore.Tensor.ceil

Rounds a tensor up to the closest integer element-wise.

mindspore.Tensor.cholesky

For details, please refer to mindspore.ops.cholesky().

mindspore.Tensor.cholesky_solve

For details, please refer to mindspore.ops.cholesky_solve().

mindspore.Tensor.choose

Construct a tensor from an index tensor and a list of tensors to choose from.

mindspore.Tensor.chunk

Cut the self Tensor into chunks sub-tensors along the specified dimension.

mindspore.Tensor.clamp

Clamps tensor values between the specified minimum value and maximum value.

mindspore.Tensor.clamp_

In-place version of mindspore.Tensor.clamp().

mindspore.Tensor.clip

Alias for mindspore.Tensor.clamp().

mindspore.Tensor.clone

Returns a copy of self.

mindspore.Tensor.col2im

For details, please refer to mindspore.ops.col2im().

mindspore.Tensor.conj

For details, please refer to mindspore.ops.conj().

mindspore.Tensor.contiguous

Converts a Tensor into a continuous-memory Tensor that contains the same data as the original Tensor.

mindspore.Tensor.copy

Return a copy of the tensor.

mindspore.Tensor.copy_

Copies the elements from src into self tensor and returns self.

mindspore.Tensor.copysign

For details, please refer to mindspore.ops.copysign().

mindspore.Tensor.cos

Computes cosine of self element-wise.

mindspore.Tensor.cosh

Computes hyperbolic cosine of self element-wise.

mindspore.Tensor.count_nonzero

Counts the number of non-zero values in the tensor input along the given dim.

mindspore.Tensor.cov

For details, please refer to mindspore.ops.cov().

mindspore.Tensor.cross

For details, please refer to mindspore.ops.cross().

mindspore.Tensor.cummax

For details, please refer to mindspore.ops.cummax().

mindspore.Tensor.cummin

For details, please refer to mindspore.ops.cummin().

mindspore.Tensor.cumprod

For details, please refer to mindspore.ops.cumprod().

mindspore.Tensor.cumsum

Computes the cumulative sum of self Tensor along dim.

mindspore.Tensor.deg2rad

For details, please refer to mindspore.ops.deg2rad().

mindspore.Tensor.diag

For details, please refer to mindspore.ops.diag().

mindspore.Tensor.diagflat

For details, please refer to mindspore.ops.diagflat().

mindspore.Tensor.diagonal

For details, please refer to mindspore.ops.diagonal().

mindspore.Tensor.diagonal_scatter

For details, please refer to mindspore.ops.diagonal_scatter().

mindspore.Tensor.diff

For details, please refer to mindspore.ops.diff().

mindspore.Tensor.digamma

For details, please refer to mindspore.ops.digamma().

mindspore.Tensor.div

Divides the self tensor by the other input tensor in floating-point type element-wise.

mindspore.Tensor.div_

In-place version of mindspore.Tensor.div().

mindspore.Tensor.divide

Alias for mindspore.Tensor.div().

mindspore.Tensor.dot

Computes the dot product of two 1D tensor.

mindspore.Tensor.double

Converts input tensor dtype to float64.

mindspore.Tensor.dsplit

For details, please refer to mindspore.ops.dsplit().

mindspore.Tensor.dtype

Return the dtype of the tensor (mindspore.dtype).

mindspore.Tensor.eigvals

For details, please refer to mindspore.ops.eigvals().

mindspore.Tensor.eq

Computes the equivalence between two tensors element-wise.

mindspore.Tensor.equal

For details, please refer to mindspore.ops.equal().

mindspore.Tensor.erf

Computes the Gauss error function of self element-wise.

mindspore.Tensor.erfc

Computes the complementary error function of self element-wise.

mindspore.Tensor.erfinv

For details, please refer to mindspore.ops.erfinv().

mindspore.Tensor.exp

Returns exponential of a tensor element-wise.

mindspore.Tensor.exp_

Inplace version of mindspore.Tensor.exp().

mindspore.Tensor.expand

For details, please refer to mindspore.ops.broadcast_to().

mindspore.Tensor.expand_as

Expand the shape of the input tensor to be the same as the another input tensor.

mindspore.Tensor.expand_dims

For details, please refer to mindspore.ops.expand_dims().

mindspore.Tensor.expm1

Returns exponential then minus 1 of a tensor element-wise.

mindspore.Tensor.fill_

Fills self tensor with the specified value .

mindspore.Tensor.fill_diagonal

Fills the main diagonal of a Tensor with a specified value and returns the result.

mindspore.Tensor.flatten

Flatten a tensor along dimensions from start_dim to end_dim.

mindspore.Tensor.flip

For details, please refer to mindspore.ops.flip().

mindspore.Tensor.fliplr

For details, please refer to mindspore.ops.fliplr().

mindspore.Tensor.flipud

For details, please refer to mindspore.ops.flipud().

mindspore.Tensor.float

Converts input tensor dtype to float32.

mindspore.Tensor.float_power

For details, please refer to mindspore.ops.float_power().

mindspore.Tensor.floor

Rounds a tensor down to the closest integer element-wise.

mindspore.Tensor.floor_

In-place version of mindspore.Tensor.floor().

mindspore.Tensor.floor_divide

Divides the self tensor by the other input tensor element-wise and round down to the closest integer.

mindspore.Tensor.floor_divide_

Divides the self tensor by the other tensor element-wise and round down to the closest integer.

mindspore.Tensor.flush_from_cache

Flush cache data to host if tensor is cache enable.

mindspore.Tensor.fmax

For details, please refer to mindspore.ops.fmax().

mindspore.Tensor.fmod

Computes the floating-point remainder of the division operation self/other.

mindspore.Tensor.fold

For details, please refer to mindspore.ops.fold().

mindspore.Tensor.frac

Calculates the fractional part of each element in self.

mindspore.Tensor.from_numpy

Convert numpy array to Tensor.

mindspore.Tensor.gather

Gather data from a tensor by indices.

mindspore.Tensor.gather_elements

For details, please refer to mindspore.ops.gather_elements().

mindspore.Tensor.gather_nd

For details, please refer to mindspore.ops.gather_nd().

mindspore.Tensor.gcd

Computes greatest common divisor of input tensors element-wise.

mindspore.Tensor.ge

Alias for mindspore.Tensor.greater_equal().

mindspore.Tensor.geqrf

For details, please refer to mindspore.ops.geqrf().

mindspore.Tensor.ger

For details, please refer to mindspore.ops.ger().

mindspore.Tensor.greater

Compare the value of the input parameters \(self > other\) element-wise, and the output result is a bool value.

mindspore.Tensor.greater_equal

Computes the boolean value of \(self >= other\) element-wise.

mindspore.Tensor.gt

For details, please refer to :func:'mindspore.Tensor.greater'.

mindspore.Tensor.H

Returns a view of a matrix (2-D tensor) conjugated and transposed.

mindspore.Tensor.half

Converts input tensor dtype to float16.

mindspore.Tensor.hardshrink

Hard Shrink activation function.

mindspore.Tensor.has_init

Whether tensor is initialized.

mindspore.Tensor.heaviside

For details, please refer to mindspore.ops.heaviside().

mindspore.Tensor.histc

Computes the histogram of self.

mindspore.Tensor.hsplit

For details, please refer to mindspore.ops.hsplit().

mindspore.Tensor.hypot

For details, please refer to mindspore.ops.hypot().

mindspore.Tensor.i0

For details, please refer to mindspore.ops.bessel_i0().

mindspore.Tensor.igamma

For details, please refer to mindspore.ops.igamma().

mindspore.Tensor.igammac

For details, please refer to mindspore.ops.igammac().

mindspore.Tensor.imag

For details, please refer to mindspore.ops.imag().

mindspore.Tensor.index_add

For details, please refer to mindspore.ops.index_add().

mindspore.Tensor.index_add_

Accumulate the elements of alpha times source into the self by adding to the index in the order given in index.

mindspore.Tensor.index_fill

For details, please refer to mindspore.ops.index_fill().

mindspore.Tensor.index_put

Based on the indices in indices, replace the corresponding elements in Tensor self with the values in values.

mindspore.Tensor.index_put_

Based on the indices in indices, replace the corresponding elements in Tensor self with the values in values.

mindspore.Tensor.index_select

Generates a new Tensor that accesses the values of self along the specified axis dimension using the indices specified in index.

mindspore.Tensor.init_data

Get the tensor format data of this Tensor.

mindspore.Tensor.inner

For details, please refer to mindspore.ops.inner().

mindspore.Tensor.inplace_update

For details, please refer to mindspore.ops.inplace_update().

mindspore.Tensor.int

Converts input tensor dtype to int32.

mindspore.Tensor.inv

For details, please refer to mindspore.ops.inv().

mindspore.Tensor.inverse

Compute the inverse of the self matrix.

mindspore.Tensor.invert

For details, please refer to mindspore.ops.invert().

mindspore.Tensor.isclose

Returns a tensor of Boolean values indicating whether each element of input is "close" to the corresponding element of other.

mindspore.Tensor.isfinite

Determine which elements are finite for each position.

mindspore.Tensor.is_complex

For details, please refer to mindspore.ops.is_complex().

mindspore.Tensor.is_contiguous

Determines whether the memory of tensor is contiguous.

mindspore.Tensor.is_floating_point

For details, please refer to mindspore.ops.is_floating_point().

mindspore.Tensor.isinf

Determines which elements are inf or -inf for each position.

mindspore.Tensor.isnan

For details, please refer to mindspore.ops.ne().

mindspore.Tensor.isneginf

Determines which elements are -inf for each position.

mindspore.Tensor.isposinf

For details, please refer to mindspore.ops.isposinf().

mindspore.Tensor.isreal

For details, please refer to mindspore.ops.isreal().

mindspore.Tensor.is_signed

Judge whether the data type of tensor is a signed data type.

mindspore.Tensor.item

Return the value of this tensor as standard Python number.

mindspore.Tensor.itemset

Insert scalar into a tensor (scalar is cast to tensor's dtype, if possible).

mindspore.Tensor.itemsize

Return the length of one tensor element in bytes.

mindspore.Tensor.lcm

For details, please refer to mindspore.ops.lcm().

mindspore.Tensor.ldexp

For details, please refer to mindspore.ops.ldexp().

mindspore.Tensor.le

Computes the boolean value of \(self <= other\) element-wise.

mindspore.Tensor.lerp

For more details, please refer to mindspore.ops.lerp().

mindspore.Tensor.less

Computes the boolean value of \(self < other\) element-wise.

mindspore.Tensor.less_equal

Computes the boolean value of \(self <= other\) element-wise.

mindspore.Tensor.log

Returns the natural logarithm of a tensor element-wise.

mindspore.Tensor.log10

Returns the logarithm to the base 10 of a tensor element-wise.

mindspore.Tensor.log1p

Returns the natural logarithm of one plus the self tensor element-wise.

mindspore.Tensor.log2

Returns the logarithm to the base 2 of a tensor element-wise

mindspore.Tensor.logaddexp

For details, please refer to mindspore.ops.logaddexp().

mindspore.Tensor.logaddexp2

For details, please refer to mindspore.ops.logaddexp2().

mindspore.Tensor.logcumsumexp

For details, please refer to mindspore.ops.logcumsumexp().

mindspore.Tensor.logdet

For details, please refer to mindspore.ops.logdet().

mindspore.Tensor.logical_and

Computes the "logical AND" of two tensors element-wise.

mindspore.Tensor.logical_not

Computes the "logical NOT" of a tensor element-wise.

mindspore.Tensor.logical_or

Computes the "logical OR" of two tensors element-wise.

mindspore.Tensor.logical_xor

Computes the "logical XOR" of two tensors element-wise.

mindspore.Tensor.logit

For details, please refer to mindspore.ops.logit().

mindspore.Tensor.logsumexp

For details, please refer to mindspore.ops.logsumexp().

mindspore.Tensor.log_normal

Fills the elements of the input tensor with log normal values initialized by given mean and std:

mindspore.Tensor.long

Converts input tensor dtype to int64.

mindspore.Tensor.lt

For more details, please refer to mindspore.Tensor.less().

mindspore.Tensor.lu_solve

For details, please refer to mindspore.ops.lu_solve().

mindspore.Tensor.masked_fill

Fills elements of Tensor with value where mask is True.

mindspore.Tensor.masked_fill_

In-place version of mindspore.Tensor.masked_fill().

mindspore.Tensor.masked_scatter

Updates the value in the "self Tensor" with the tensor value according to the mask, and returns a Tensor.

mindspore.Tensor.masked_select

Returns a new 1-D Tensor which indexes self according to the boolean mask.

mindspore.Tensor.matmul

Returns the matrix product of two tensors.

mindspore.Tensor.max

Returns the maximum value of the self tensor.

mindspore.Tensor.maximum

Computes the maximum of input tensors element-wise.

mindspore.Tensor.mean

Reduces all dimension of a tensor by averaging all elements in the dimension, by default.

mindspore.Tensor.median

Computes the median and indices of input tensor.

mindspore.Tensor.t

Transpose self .

mindspore.Tensor.mH

Accessing this property is equivalent to Calling self.adjoint().

mindspore.Tensor.min

Returns the minimum value of the self tensor.

mindspore.Tensor.minimum

Computes the minimum of input tensors element-wise.

mindspore.Tensor.mm

Returns the matrix product of two arrays.

mindspore.Tensor.moveaxis

For details, please refer to mindspore.ops.moveaxis().

mindspore.Tensor.movedim

For details, please refer to mindspore.ops.movedim().

mindspore.Tensor.move_to

Copy Tensor to target device synchronously or asynchronously, default synchronously.

mindspore.Tensor.msort

For details, please refer to mindspore.ops.msort().

mindspore.Tensor.mT

Returns the Tensor that exchanges the last two dimensions.

mindspore.Tensor.mul

Multiplies two tensors element-wise.

mindspore.Tensor.mul_

Multiplies two tensors element-wise.

mindspore.Tensor.multinomial

For details, please refer to mindspore.ops.multinomial().

mindspore.Tensor.multiply

For details, please refer to mindspore.ops.mul().

mindspore.Tensor.mvlgamma

For details, please refer to mindspore.ops.mvlgamma().

mindspore.Tensor.nan_to_num

Replace the NaN, positive infinity and negative infinity values of the self with the specified values in nan, posinf and neginf respectively.

mindspore.Tensor.nanmean

For details, please refer to mindspore.ops.nanmean().

mindspore.Tensor.nanmedian

For details, please refer to mindspore.ops.nanmedian().

mindspore.Tensor.nansum

Computes sum of input Tensor over a given dimension, treating NaNs as zero.

mindspore.Tensor.narrow

Obtains a tensor of a specified length at a specified start position along a specified axis.

mindspore.Tensor.nbytes

Return the total number of bytes taken by the tensor.

mindspore.Tensor.ndim

Return the number of tensor dimensions.

mindspore.Tensor.ndimension

Alias for mindspore.Tensor.ndim.

mindspore.Tensor.ne

Alias for mindspore.Tensor.not_equal().

mindspore.Tensor.neg

Returns a tensor with negative values of self element-wise.

mindspore.Tensor.negative

Alias for mindspore.Tensor.neg().

mindspore.Tensor.nelement

Alias for mindspore.Tensor.numel().

mindspore.Tensor.new_ones

Return a tensor of size filled with ones.

mindspore.Tensor.new_zeros

Return a tensor of size filled with zeros.

mindspore.Tensor.nextafter

For details, please refer to mindspore.ops.nextafter().

mindspore.Tensor.nonzero

Return the positions of all non-zero values.

mindspore.Tensor.norm

For details, please refer to mindspore.ops.norm().

mindspore.Tensor.normal_

Update the self tensor in place by generating random numbers sampled from the normal distribution which constructed by the parameters mean and std.

mindspore.Tensor.not_equal

Computes the non-equivalence of two tensors element-wise.

mindspore.Tensor.numel

Returns a Scalar of type int that represents the total number of elements in the Tensor.

mindspore.Tensor.numpy

Alias for mindspore.Tensor.asnumpy().

mindspore.Tensor.orgqr

For details, please refer to mindspore.ops.orgqr().

mindspore.Tensor.ormqr

For details, please refer to mindspore.ops.ormqr(), Args input2 and input3 correspond to the args tau and other of mindspore.ops.ormqr().

mindspore.Tensor.outer

Return outer product of self and vec2.

mindspore.Tensor.permute

Tensor.permute supports unpacking the axis argument automatically when it is passed as an indefinite number of positional arguments, which has a slight difference from the input parameter of mindspore.ops.permute().

mindspore.Tensor.positive

For details, please refer to mindspore.ops.positive().

mindspore.Tensor.pow

Calculates the exponent power of each element in self.

mindspore.Tensor.prod

Reduces a dimension of a tensor by multiplying all elements in the dimension, by default.

mindspore.Tensor.ptp

The name of the function comes from the acronym for "peak to peak".

mindspore.Tensor.rad2deg

For details, please refer to mindspore.ops.rad2deg().

mindspore.Tensor.random_

Fill the tensor with numbers sampled from a discrete uniform distribution over an interval \([from\_, to-1]\).

mindspore.Tensor.random_categorical

For details, please refer to mindspore.ops.random_categorical().

mindspore.Tensor.ravel

Return a contiguous flattened tensor.

mindspore.Tensor.real

For details, please refer to mindspore.ops.real().

mindspore.Tensor.reciprocal

Returns reciprocal of a tensor element-wise.

mindspore.Tensor.register_hook

Registers a backward hook for tensor.

mindspore.Tensor.remainder

Computes the remainder of self divided by other element-wise.

mindspore.Tensor.renorm

For details, please refer to mindspore.ops.renorm().

mindspore.Tensor.repeat

Repeat elements of a tensor.

mindspore.Tensor.repeat_interleave

Repeat elements of a tensor along a dim, like mindspore.numpy.repeat().

mindspore.Tensor.reshape

Rearranges self Tensor based on the given shape.

mindspore.Tensor.reshape_as

Change the shape of the Tensor to the shape of other without changing the data.

mindspore.Tensor.resize

Changes shape and size of tensor in-place.

mindspore.Tensor.reverse

For details, please refer to mindspore.ops.flip().

mindspore.Tensor.reverse_sequence

For details, please refer to mindspore.ops.reverse_sequence().

mindspore.Tensor.roll

mindspore.Tensor.rot90

For details, please refer to mindspore.ops.rot90().

mindspore.Tensor.round

Returns half to even of a tensor element-wise.

mindspore.Tensor.rsqrt

Computes reciprocal of square root of self tensor element-wise.

mindspore.Tensor.scatter

Update the value in src to self according to the specified index.

mindspore.Tensor.scatter_

Update the value in src to update self according to the specified index.

mindspore.Tensor.scatter_add

Add all elements in src to the index specified by index to self along dimension specified by dim.

mindspore.Tensor.scatter_add_

Add all elements in src to the index specified by index to self along dimension specified by dim, scatter_add is an in-place operation.

mindspore.Tensor.scatter_div

For details, please refer to mindspore.ops.scatter_div().

mindspore.Tensor.scatter_max

For details, please refer to mindspore.ops.scatter_max().

mindspore.Tensor.scatter_min

For details, please refer to mindspore.ops.scatter_min().

mindspore.Tensor.scatter_mul

For details, please refer to mindspore.ops.scatter_mul().

mindspore.Tensor.scatter_sub

Creates a new tensor by subtracting the values from the positions in self tensor indicated by indices, with values from updates.

mindspore.Tensor.searchsorted

Finds indices where elements should be inserted to maintain order.

mindspore.Tensor.select

Slices the self tensor along the selected dimension at the given index.

mindspore.Tensor.select_scatter

For details, please refer to mindspore.ops.select_scatter().

mindspore.Tensor.set_const_arg

Specify whether the tensor is a constant when it is used for the argument of a network.

mindspore.Tensor.sgn

For details, please refer to mindspore.ops.sgn().

mindspore.Tensor.shape

For details, please refer to mindspore.ops.shape().

mindspore.Tensor.short

Return a copy of the tensor, cast to int16 type, equivalent to self.astype(mstype.int16).

mindspore.Tensor.sigmoid

Computes Sigmoid of self element-wise.

mindspore.Tensor.sign

For details, please refer to mindspore.ops.sign().

mindspore.Tensor.signbit

For details, please refer to mindspore.ops.signbit().

mindspore.Tensor.sin

Computes sine of self element-wise.

mindspore.Tensor.sinc

Computes the normalized sinc of self.

mindspore.Tensor.sinh

Computes hyperbolic sine of the self element-wise.

mindspore.Tensor.size

For details, please refer to mindspore.ops.size().

mindspore.Tensor.slice_scatter

For details, please refer to mindspore.ops.slice_scatter().

mindspore.Tensor.slogdet

For details, please refer to mindspore.ops.slogdet().

mindspore.Tensor.softmax

For details, please refer to mindspore.ops.softmax().

mindspore.Tensor.sort

Sorts the elements of the self tensor along the given dimension in the specified order.

mindspore.Tensor.split

Splits the Tensor into chunks along the given dim.

mindspore.Tensor.sqrt

Returns sqrt of self element-wise.

mindspore.Tensor.square

Returns square of self element-wise.

mindspore.Tensor.squeeze

For details, please refer to mindspore.ops.squeeze().

mindspore.Tensor.std

For details, please refer to mindspore.ops.std().

mindspore.Tensor.storage_offset

Tensor's offset in the underlying storage in terms of the number of storage elements.

mindspore.Tensor.stride

The stride to jump from one element to the next in the input dim.

mindspore.Tensor.strides

Return the tuple of bytes to step in each dimension when traversing a tensor.

mindspore.Tensor.sub

Subtracts scaled other value from self Tensor.

mindspore.Tensor.sub_

For details, please refer to mindspore.mint.sub().

mindspore.Tensor.subtract

This interface is deprecated from version 2.4 and will be removed in a future version.

mindspore.Tensor.sum

Calculate sum of Tensor elements over a given dim.

mindspore.Tensor.sum_to_size

Sum self Tensor to the size.

mindspore.Tensor.svd

For details, please refer to mindspore.ops.svd().

mindspore.Tensor.swapaxes

For details, please refer to mindspore.ops.swapaxes().

mindspore.Tensor.swapdims

For details, please refer to mindspore.ops.swapdims().

mindspore.Tensor.T

Return the transposed tensor.

mindspore.Tensor.t

Transpose self .

mindspore.Tensor.take

Takes elements from a tensor along an axis.

mindspore.Tensor.tan

Computes tangent of self element-wise.

mindspore.Tensor.tanh

Computes hyperbolic tangent of self element-wise.

mindspore.Tensor.tensor_split

For details, please refer to mindspore.ops.tensor_split().

mindspore.Tensor.tile

Replicates an tensor with given dims times.

mindspore.Tensor.to

Performs tensor dtype conversion.

mindspore.Tensor.to_coo

Convert a Tensor to COOTensor.

mindspore.Tensor.to_csr

Convert a Tensor to CSRTensor.

mindspore.Tensor.tolist

Convert a Tensor to List.

mindspore.Tensor.topk

Finds values and indices of the k largest or smallest entries along a given dimension.

mindspore.Tensor.trace

Return the sum along diagonals of the tensor.

mindspore.Tensor.transpose

Interchange two axes of a tensor.

mindspore.Tensor.triangular_solve

For details, please refer to mindspore.mint.triangular_solve().

mindspore.Tensor.tril

Returns the lower triangle part of input (elements that contain the diagonal and below), and set the other elements to zeros.

mindspore.Tensor.triu

Returns the upper triangle part of 'self' (elements that contain the diagonal and below), and set the other elements to zeros.

mindspore.Tensor.true_divide

Alias for Tensor.div() with \(rounding\_mode=None\).

mindspore.Tensor.trunc

Returns a new tensor with the truncated integer values of the elements of the input tensor.

mindspore.Tensor.type

Change the dtype of the Tensor to the dtype .

mindspore.Tensor.type_as

Returns self tensor cast to the type of the with the input other tensor.

mindspore.Tensor.unbind

Unbind the tensor dimension in specified axis.

mindspore.Tensor.unfold

For details, please refer to mindspore.ops.unfold().

mindspore.Tensor.uniform

Generates random numbers that follows a uniform distribution within the half-open interval \([from\_, to)\).

mindspore.Tensor.uniform_

Update the self tensor in place by generating random numbers sampled from uniform distribution in the half-open interval \([from\_, to)\).

mindspore.Tensor.unique

Returns the unique elements of self.

mindspore.Tensor.unique_consecutive

For details, please refer to mindspore.ops.unique_consecutive().

mindspore.Tensor.unique_with_pad

For details, please refer to mindspore.ops.unique_with_pad().

mindspore.Tensor.unsorted_segment_max

For details, please refer to mindspore.ops.unsorted_segment_max().

mindspore.Tensor.unsorted_segment_min

For details, please refer to mindspore.ops.unsorted_segment_min().

mindspore.Tensor.unsorted_segment_prod

For details, please refer to mindspore.ops.unsorted_segment_prod().

mindspore.Tensor.unsqueeze

Adds an additional dimension to self at the given dim.

mindspore.Tensor.var

Compute the variance along the specified axis.

mindspore.Tensor.view

Reshape the tensor according to the input shape.

mindspore.Tensor.view_as

View self Tensor as the same shape as other .

mindspore.Tensor.vsplit

For details, please refer to mindspore.ops.vsplit().

mindspore.Tensor.where

Selects elements from self or y based on condition and returns a tensor.

mindspore.Tensor.xdivy

For details, please refer to mindspore.ops.xdivy().

mindspore.Tensor.xlogy

For details, please refer to mindspore.ops.xlogy().

mindspore.Tensor.zero_

Return a tensor filled with zeros.