Experimental#
- class ivy.data_classes.array.experimental.activations._ArrayWithActivationsExperimental[source]#
- _abc_impl = <_abc_data object>#
- logit(*, eps=None, out=None)[source]#
ivy.Array instance method variant of ivy.logit. This method simply wraps the function, and so the docstring for ivy.logit also applies to this method with minimal changes.
- Parameters:
self – Input array.
eps (
Optional
[float
]) – When eps is None the function outpus NaN where x < 0 or x > 1. (default:None
) and inf or -inf where x = 1 or x = 0, respectively. Otherwise if eps is defined, x is clamped to [eps, 1 - eps]out (
Optional
[Array
]) – Optional output array. (default:None
)
- Return type:
Array
- Returns:
ret – Array containing elementwise logits of x.
Examples
>>> x = ivy.array([1, 0, 0.9]) >>> z = x.logit() >>> print(z) ivy.array([ inf, -inf, 2.19722438])
>>> x = ivy.array([1, 2, -0.9]) >>> z = x.logit(eps=0.2) >>> print(z) ivy.array([ 1.38629448, 1.38629448, -1.38629436])
- logsigmoid()[source]#
ivy.Array instance method variant of ivy.logsigmoid. This method simply wraps the function, and so the docstring for ivy.logsigmoid also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array.- Return type:
Array
- Returns:
Array with same shape as input with Log-sigmoid applied to every element.
Examples
>>> x = ivy.array([-1., 2., 4., -10.]) >>> z = x.logsigmoid() >>> print(z) ivy.array([ -1.31326175, -0.126928 , -0.01814993, -10.00004578])
>>> x = ivy.array([-2.5, 1., 0, 4.5]) >>> z = x.logsigmoid()) >>> print(z) ivy.array([-2.57888985, -0.31326169, -0.69314718, -0.01104775])
- prelu(slope, /, *, out=None)[source]#
Prelu takes input data (Array) and slope array as input,
and produces one output data (array) where the function f(x) = slope * x for x < 0, f(x) = x for x >= 0., is applied to the data array elementwise. This operator supports unidirectional broadcasting (array slope should be unidirectional broadcastable to input tensor X);
- Parameters:
self – input array.
slope (
Union
[float
,NativeArray
,Array
]) – Slope Array. The shape of slope can be smaller than first input X; if so, its shape must be unidirectional broadcastable to X.out (
Optional
[Array
]) – Optional output array. (default:None
)
- Return type:
Array
- Returns:
ret – input array with prelu applied elementwise.
- relu6(*, out=None)[source]#
Apply the rectified linear unit 6 function element-wise.
- Parameters:
self – input array
out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
) It must have a shape that the inputs broadcast to.
- Return type:
Array
- Returns:
ret – an array containing the rectified linear unit 6 activation of each element in input.
Examples
With
ivy.Array
input:>>> x = ivy.array([-1., 0., 1., 2., 3., 4., 5., 6., 7.]) >>> y = ivy.relu6(x) >>> print(y) ivy.array([0., 0., 1., 2., 3., 4., 5., 6., 6.])
>>> x = ivy.array([-1., 0., 1., 2., 3., 4., 5., 6., 7.]) >>> y = ivy.zeros(9) >>> ivy.relu6(x, out = y) >>> print(y) ivy.array([0., 0., 1., 2., 3., 4., 5., 6., 6.])
With
ivy.Container
input:>>> x = { a: ivy.array([-3., -2., -1., 0., 1., 2., 3., 4., 5.]), b: ivy.array([1., 2., 3., 4., 5., 6., 7., 8., 9.]) } >>> x = ivy.relu6(x, out=x) >>> print(x) { a: ivy.array([0., 0., 0., 0., 1., 2., 3., 4., 5.]), b: ivy.array([1., 2., 3., 4., 5., 6., 6., 6., 6.]) }
- selu(*, out=None)[source]#
Apply the scaled exponential linear unit function element-wise.
- Parameters:
self – input array
out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
) It must have a shape that the inputs broadcast to.
- Return type:
Array
- Returns:
ret – an array containing the scaled exponential linear unit activation of each element in input.
Examples
With
ivy.Array
input:>>> x = ivy.array([-1., 0., 1., 2., 3., 4., 5., 6., 7.]) >>> y = x.selu() >>> print(y) ivy.array([-1.11133075, 0., 1.05070102, 2.10140204, 3.15210295, 4.20280409, 5.25350523, 6.30420589, 7.35490704])
>>> x = ivy.array([-1., 0., 1., 2., 3., 4., 5., 6., 7.]) >>> y = ivy.zeros(9) >>> x.selu(out = y) >>> print(y) ivy.array([-1.11133075, 0., 1.05070102, 2.10140204, 3.15210295, 4.20280409, 5.25350523, 6.30420589, 7.35490704])
- silu(*, out=None)[source]#
ivy.Array instance method variant of ivy.silu. This method simply wraps the function, and so the docstring for ivy.silu also applies to this method with minimal changes.
- Parameters:
self (
Array
) – input array.out (
Optional
[Array
]) – optional output array, for writing the result to. It must have a shape (default:None
) that the inputs broadcast to.
Examples
>>> x = ivy.array([-1., 0., 1.]) >>> y = x.silu() >>> print(y) ivy.array([-0.26894143, 0. , 0.73105854])
- Return type:
Array
- thresholded_relu(*, threshold=0, out=None)[source]#
ivy.Array instance method variant of ivy.thresholded_relu. This method simply wraps the function, and so the docstring for ivy.thresholded_relu also applies to this method with minimal changes.
- Parameters:
self (
Array
) – input array.threshold (
Union
[int
,float
]) – threshold value above which the activation is linear. Default:0
. (default:0
)out (
Optional
[Array
]) – optional output array, for writing the result to. It must have a shape (default:None
) that the inputs broadcast to.
- Return type:
Array
- Returns:
ret – an array with the relu activation function applied element-wise with custom threshold.
Examples
>>> x = ivy.array([-1., .2, 1.]) >>> y = x.thresholded_relu(threshold=0.5) >>> print(y) ivy.array([0., 0., 1.])
- class ivy.data_classes.array.experimental.conversions._ArrayWithConversionsExperimental[source]#
- _abc_impl = <_abc_data object>#
- class ivy.data_classes.array.experimental.creation._ArrayWithCreationExperimental[source]#
- _abc_impl = <_abc_data object>#
- eye_like(*, k=0, dtype=None, device=None, out=None)[source]#
ivy.Array instance method variant of ivy.eye_like. This method simply wraps the function, and so the docstring for ivy.eye_like also applies to this method with minimal changes.
- Parameters:
self (
Array
) – input array from which to derive the output array shape.k (
int
) – index of the diagonal. A positive value refers to an upper diagonal, (default:0
) a negative value to a lower diagonal, and 0 to the main diagonal. Default:0
.dtype (
Optional
[Union
[Dtype
,NativeDtype
]]) – output array data type. Ifdtype
isNone
, the output array data type (default:None
) must be inferred fromself
. Default:None
.device (
Optional
[Union
[Device
,NativeDevice
]]) – device on which to place the created array. Ifdevice
isNone
, the (default:None
) output array device must be inferred fromself
. Default:None
.out (
Optional
[Array
]) – optional output array, for writing the result to. It must have a shape that (default:None
) the inputs broadcast to.
- Return type:
Array
- Returns:
ret – an array having the same shape as
self
and filled withones
in diagonalk
andzeros
elsewhere.
Examples
>>> x = ivy.array([[2, 3, 8],[1, 2, 1]]) >>> y = x.eye_like() >>> print(y) ivy.array([[1., 0., 0.], 0., 1., 0.]])
- class ivy.data_classes.array.experimental.data_type._ArrayWithData_typeExperimental[source]#
- _abc_impl = <_abc_data object>#
- class ivy.data_classes.array.experimental.device._ArrayWithDeviceExperimental[source]#
- _abc_impl = <_abc_data object>#
- class ivy.data_classes.array.experimental.elementwise._ArrayWithElementWiseExperimental[source]#
- _abc_impl = <_abc_data object>#
- allclose(x2, /, *, rtol=1e-05, atol=1e-08, equal_nan=False, out=None)[source]#
ivy.Array instance method variant of ivy.allclose. This method simply wraps the function, and so the docstring for ivy.allclose also applies to this method with minimal changes.
- Parameters:
self (
Array
) – First input array.x2 (
Array
) – Second input array.rtol (
float
) – The relative tolerance parameter. (default:1e-05
)atol (
float
) – The absolute tolerance parameter. (default:1e-08
)equal_nan (
bool
) – Whether to compare NaN’s as equal. If True, NaN’s in a will be (default:False
) considered equal to NaN’s in b in the output array.out (
Optional
[Container
]) – Alternate output array in which to place the result. (default:None
) The default is None.
- Return type:
bool
- Returns:
ret – Returns True if the two arrays are equal within the given tolerance; False otherwise.
Examples
>>> x1 = ivy.array([1e10, 1e-7]) >>> x2 = ivy.array([1.00001e10, 1e-8]) >>> y = x1.allclose(x2) >>> print(y) ivy.array(False)
>>> x1 = ivy.array([1.0, ivy.nan]) >>> x2 = ivy.array([1.0, ivy.nan]) >>> y = x1.allclose(x2, equal_nan=True) >>> print(y) ivy.array(True)
>>> x1 = ivy.array([1e-10, 1e-10]) >>> x2 = ivy.array([1.00001e-10, 1e-10]) >>> y = x1.allclose(x2, rtol=0.005, atol=0.0) >>> print(y) ivy.array(True)
- angle(*, deg=False, out=None)[source]#
ivy.Array instance method variant of ivy.angle. This method simply wraps the function, and so the docstring for ivy.angle also applies to this method with minimal changes.
- Parameters:
z – Array-like input.
deg (
bool
) – optional bool. (default:False
)out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – Returns an array of angles for each complex number in the input. If def is False(default), angle is calculated in radian and if def is True, then angle is calculated in degrees.
Examples
>>> ivy.set_backend('tensorflow') >>> z = ivy.array([-1 + 1j, -2 + 2j, 3 - 3j]) >>> z ivy.array([-1.+1.j, -2.+2.j, 3.-3.j]) >>> ivy.angle(z) ivy.array([ 2.35619449, 2.35619449, -0.78539816]) >>> ivy.set_backend('numpy') >>> ivy.angle(z,deg=True) ivy.array([135., 135., -45.])
- binarizer(*, threshold=0, out=None)[source]#
Map the values of the input tensor to either 0 or 1, element-wise, based on the outcome of a comparison against a threshold value.
- Parameters:
self (
Array
) – Data to be binarizedthreshold (
float
) – Values greater than this are (default:0
) mapped to 1, others to 0.out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
) It must have a shape that the inputs broadcast to.
- Return type:
Array
- Returns:
ret – Binarized output data
- conj(*, out=None)[source]#
ivy.Array instance method variant of ivy.conj. This method simply wraps the function, and so the docstring for ivy.conj also applies to this method with minimal changes.
- Parameters:
self (
Array
) – input array.out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
) It must have a shape that the inputs broadcast to.
- Return type:
Array
- Returns:
ret – an array containing the complex conjugates of values in the input array, with the same dtype as the input array.
Examples
>>> x = ivy.array([4+3j, 6+2j, 1-6j]) >>> x.conj() ivy.array([4-3j, 6-2j, 1+6j])
- copysign(x2, /, *, out=None)[source]#
ivy.Array instance method variant of ivy.copysign. This method simply wraps the function, and so the docstring for ivy.copysign also applies to this method with minimal changes.
- Parameters:
x1 – Array or scalar to change the sign of
x2 (
Union
[Array
,NativeArray
,Number
]) – Array or scalar from which the new signs are applied Unsigned zeroes are considered positive.out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – x1 with the signs of x2. This is a scalar if both x1 and x2 are scalars.
Examples
>>> x1 = ivy.array([0, 1, 2, 3]) >>> x2 = ivy.array([-1, 1, -2, 2]) >>> x1.copysign(x2) ivy.array([-0., 1., -2., 3.]) >>> x2.copysign(-1) ivy.array([-1., -1., -2., -2.])
- count_nonzero(*, axis=None, keepdims=False, dtype=None, out=None)[source]#
ivy.Array instance method variant of ivy.count_nonzero. This method simply wraps the function, and so the docstring for ivy.count_nonzero also applies to this method with minimal changes.
- Parameters:
self (
Array
) – input array for which to count non-zeros.axis (
Optional
[Union
[int
,Tuple
[int
,...
]]]) – optional axis or tuple of axes along which to count non-zeros. Default is (default:None
) None, meaning that non-zeros will be counted along a flattened version of the input array.keepdims (
bool
) – optional, if this is set to True, the axes that are counted are left in the (default:False
) result as dimensions with size one. With this option, the result will broadcast correctly against the input array.dtype (
Optional
[Union
[Dtype
,NativeDtype
]]) – optional output dtype. Default is of type integer. (default:None
)out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – Number of non-zero values in the array along a given axis. Otherwise, the total number of non-zero values in the array is returned.
Examples
>>> x = ivy.array([1, 2, 3]) >>> x.count_nonzero() ivy.array(3) >>> x = ivy.array([[[0,1],[2,3]],[[4,5],[6,7]]]) >>> x.count_nonzero(axis=0) ivy.array([[1, 2], [2, 2]]) >>> x = ivy.array([[[0,1],[2,3]],[[4,5],[6,7]]]) >>> x.count_nonzero(axis=(0,1), keepdims=True) ivy.array([[[3, 4]]])
- diff(*, n=1, axis=-1, prepend=None, append=None, out=None)[source]#
ivy.Array instance method variant of ivy.diff. This method simply wraps the function, and so the docstring for ivy.diff also applies to this method with minimal changes.
- Parameters:
self (
Array
) – array-like input.n (
int
) – The number of times values are differenced. If zero, the input is returned (default:1
) as-is.axis (
int
) – The axis along which the difference is taken, default is the last axis. (default:-1
)prepend (
Optional
[Union
[Array
,NativeArray
,int
,list
,tuple
]]) – Values to prepend/append to x along given axis prior to performing the (default:None
) difference. Scalar values are expanded to arrays with length 1 in the direction of axis and the shape of the input array in along all other axes. Otherwise the dimension and shape must match x except along axis.append (
Optional
[Union
[Array
,NativeArray
,int
,list
,tuple
]]) – Values to prepend/append to x along given axis prior to performing the (default:None
) difference. Scalar values are expanded to arrays with length 1 in the direction of axis and the shape of the input array in along all other axes. Otherwise the dimension and shape must match x except along axis.out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – Returns the n-th discrete difference along the given axis.
Examples
>>> x = ivy.array([1, 2, 4, 7, 0]) >>> x.diff() ivy.array([ 1, 2, 3, -7])
- fix(*, out=None)[source]#
ivy.Array instance method variant of ivy.fix. This method simply wraps the function, and so the docstring for ivy.fix also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Array input.out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – Array of floats with elements corresponding to input elements rounded to nearest integer towards zero, element-wise.
Examples
>>> x = ivy.array([2.1, 2.9, -2.1]) >>> x.fix() ivy.array([ 2., 2., -2.])
- float_power(x2, /, *, out=None)[source]#
ivy.Array instance method variant of ivy.float_power. This method simply wraps the function, and so the docstring for ivy.float_power also applies to this method with minimal changes.
- Parameters:
self (
Union
[Array
,float
,list
,tuple
]) – Array-like with elements to raise in power.x2 (
Union
[Array
,float
,list
,tuple
]) – Array-like of exponents. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – The bases in x1 raised to the exponents in x2. This is a scalar if both x1 and x2 are scalars
Examples
>>> x1 = ivy.array([1, 2, 3, 4, 5]) >>> x1.float_power(3) ivy.array([1., 8., 27., 64., 125.]) >>> x1 = ivy.array([1, 2, 3, 4, 5]) >>> x2 = ivy.array([2, 3, 3, 2, 1]) >>> x1.float_power(x2) ivy.array([1., 8., 27., 16., 5.])
- fmax(x2, /, *, out=None)[source]#
ivy.Array instance method variant of ivy.fmax. This method simply wraps the function, and so the docstring for ivy.fmax also applies to this method with minimal changes.
- Parameters:
self (
Array
) – First input array.x2 (
Array
) – Second input arrayout (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – Array with element-wise maximums.
Examples
>>> x1 = ivy.array([2, 3, 4]) >>> x2 = ivy.array([1, 5, 2]) >>> ivy.fmax(x1, x2) ivy.array([ 2., 5., 4.])
>>> x1 = ivy.array([ivy.nan, 0, ivy.nan]) >>> x2 = ivy.array([0, ivy.nan, ivy.nan]) >>> x1.fmax(x2) ivy.array([ 0, 0, nan])
- fmod(x2, /, *, out=None)[source]#
ivy.Array instance method variant of ivy.fmod. This method simply wraps the function, and so the docstring for ivy.fmod also applies to this method with minimal changes.
- Parameters:
self (
Array
) – First input array.x2 (
Array
) – Second input arrayout (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – Array with element-wise remainder of divisions.
Examples
>>> x1 = ivy.array([2, 3, 4]) >>> x2 = ivy.array([1, 5, 2]) >>> x1.fmod(x2) ivy.array([ 0, 3, 0])
>>> x1 = ivy.array([ivy.nan, 0, ivy.nan]) >>> x2 = ivy.array([0, ivy.nan, ivy.nan]) >>> x1.fmod(x2) ivy.array([ nan, nan, nan])
- frexp(*, out=None)[source]#
ivy.Array instance method variant of ivy.frexp. This method simply wraps the function, and so the docstring for ivy.frexp also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array.out (
Optional
[Tuple
[Array
,Array
]]) – Alternate output array in which to place the result. (default:None
) The default is None.
- Return type:
Array
- Returns:
ret – The next representable values of x1 in the direction of x2.
Examples
>>> x = ivy.array([1.0, 2.0, 3.0]) >>> x.frexp() ivy.array([[0.5, 0.5, 0.75], [1, 2, 2]])
- gcd(x2, /, *, out=None)[source]#
ivy.Array instance method variant of ivy.gcd. This method simply wraps the function, and so the docstring for ivy.gcd also applies to this method with minimal changes.
- Parameters:
self (
Union
[Array
,int
,list
,tuple
]) – First array-like input.x2 (
Union
[Array
,int
,list
,tuple
]) – Second array-like inputout (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
Examples
>>> x1 = ivy.array([1, 2, 3]) >>> x2 = ivy.array([4, 5, 6]) >>> x1.gcd(x2) ivy.array([1., 1., 3.]) >>> x1 = ivy.array([1, 2, 3]) >>> x1.gcd(10) ivy.array([1., 2., 1.])
- gradient(*, spacing=1, edge_order=1, axis=None)[source]#
Calculate gradient of x with respect to (w.r.t.) spacing.
- Parameters:
self (
Union
[Array
,NativeArray
]) – input array representing outcomes of the functionspacing (
Union
[int
,list
,tuple
]) – if not given, indices of x will be used (default:1
) if scalar indices of x will be scaled with this value if array gradient of x w.r.t. spacingedge_order (
int
) – 1 or 2, for ‘first order’ and ‘second order’ estimation (default:1
) of boundary values of gradient respectively. Note: jax supports edge_order=1 case onlyaxis (
Optional
[Union
[int
,list
,tuple
]]) – dimension(s) to approximate the gradient over (default:None
) by default partial gradient is computed in every dimention
- Return type:
Union
[Array
,List
[Array
]]- Returns:
ret – Array with values computed from gradient function from inputs
Examples
>>> spacing = (ivy.array([-2., -1., 1., 4.]),) >>> x = ivy.array([4., 1., 1., 16.], ) >>> ivy.gradient(x, spacing=spacing) ivy.array([-3., -2., 2., 5.])
>>> x = ivy.array([[1, 2, 4, 8], [10, 20, 40, 80]]) >>> ivy.gradient(x) [ivy.array([[ 9., 18., 36., 72.], [ 9., 18., 36., 72.]]), ivy.array([[ 1. , 1.5, 3. , 4. ], [10. , 15. , 30. , 40. ]])]
>>> x = ivy.array([[1, 2, 4, 8], [10, 20, 40, 80]]) >>> ivy.gradient(x, spacing=2.0) [ivy.array([[ 4.5, 9. , 18. , 36. ], [ 4.5, 9. , 18. , 36. ]]), ivy.array([[ 0.5 , 0.75, 1.5 , 2. ], [ 5. , 7.5 , 15. , 20. ]])]
>>> x = ivy.array([[1, 2, 4, 8], [10, 20, 40, 80]]) >>> ivy.gradient(x, axis=1) ivy.array([[ 1. , 1.5, 3. , 4. ], [10. , 15. , 30. , 40. ]])
>>> x = ivy.array([[1, 2, 4, 8], [10, 20, 40, 80]]) >>> ivy.gradient(x, spacing=[3., 2.]) [ivy.array([[ 3., 6., 12., 24.], [ 3., 6., 12., 24.]]), ivy.array([[ 0.5 , 0.75, 1.5 , 2. ], [ 5. , 7.5 , 15. , 20. ]])]
>>> spacing = (ivy.array([0, 2]), ivy.array([0, 3, 6, 9])) >>> ivy.gradient(x, spacing=spacing) [ivy.array([[ 4.5, 9. , 18. , 36. ], [ 4.5, 9. , 18. , 36. ]]), ivy.array([[ 0.33333333, 0.5, 1., 1.33333333], [ 3.33333333, 5. , 10. , 13.33333333]])]
- hypot(x2, /, *, out=None)[source]#
ivy.Array instance method variant of ivy.hypot. This method simply wraps the function, and so the docstring for ivy.hypot also applies to this method with minimal changes.
- Parameters:
self (
Array
) – First input arrayx2 (
Array
) – Second input arrayout (
Optional
[Array
]) – Optional output array, for writing the result to. It must have a shape that (default:None
) the inputs broadcast to.
- Return type:
Array
- Returns:
ret – An array containing the hypotenuse computed from each element of the input arrays.
Examples
>>> x = ivy.array([3.0, 4.0, 5.0]) >>> y = ivy.array([4.0, 5.0, 6.0]) >>> x.hypot(y) ivy.array([5.0, 6.4031, 7.8102])
- imag(*, out=None)[source]#
ivy.Array instance method variant of ivy.imag. This method simply wraps the function, and so the docstring for ivy.imag also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Array-like input.out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – Returns an array with the imaginary part of complex numbers.
Examples
>>> b = ivy.array(np.array([1+2j, 3+4j, 5+6j])) >>> b ivy.array([1.+2.j, 3.+4.j, 5.+6.j]) >>> ivy.imag(b) ivy.array([2., 4., 6.]) >>> b.imag() ivy.array([2., 4., 6.])
- isclose(b, /, *, rtol=1e-05, atol=1e-08, equal_nan=False, out=None)[source]#
ivy.Array instance method variant of ivy.isclose. This method simply wraps the function, and so the docstring for ivy.isclose also applies to this method with minimal changes.
- Parameters:
self (
Array
) – First input array.b (
Array
) – Second input array.rtol (
float
) – The relative tolerance parameter. (default:1e-05
)atol (
float
) – The absolute tolerance parameter. (default:1e-08
)equal_nan (
bool
) – Whether to compare NaN’s as equal. If True, NaN’s in a will be (default:False
) considered equal to NaN’s in b in the output array.out (
Optional
[Array
]) – Alternate output array in which to place the result. (default:None
) The default is None.
- Return type:
Array
- Returns:
ret – A new array holding the result is returned unless out is specified, in which it is returned.
Examples
>>> a = ivy.array([[ 2.1, 3.4, ivy.nan], [ivy.nan, 2.4, 2.1]]) >>> b = ivy.array([[ 2.1, 3.4, ivy.nan], [ivy.nan, 2.4, 2.1]]) >>> a.isclose(b) ivy.array([[True, True, False], [False, True, True]]) >>> a.isclose(b, equal_nan=True) ivy.array([[True, True, True], [True, True, True]]) >>> a=ivy.array([1.0, 2.0]) >>> b=ivy.array([1.0, 2.001]) >>> a.isclose(b, atol=0.0) ivy.array([True, False]) >>> a.isclose(b, rtol=0.01, atol=0.0) ivy.array([True, True])
- ldexp(x2, /, *, out=None)[source]#
ivy.Array instance method variant of ivy.ldexp. This method simply wraps the function, and so the docstring for ivy.ldexp also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array.x2 (
Array
) – The array of exponents.out (
Optional
[Array
]) – Alternate output array in which to place the result. (default:None
) The default is None.
- Return type:
Array
- Returns:
ret – The next representable values of x1 in the direction of x2.
Examples
>>> x = ivy.array([1.0, 2.0, 3.0]) >>> y = ivy.array([3.0, 2.0, 1.0]) >>> x.ldexp(y) ivy.array([8.0, 8.0, 6.0])
- lerp(end, weight, /, *, out=None)[source]#
ivy.Array instance method variant of ivy.lerp. This method simply wraps the function, and so the docstring for ivy.lerp also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Array of starting pointsend (
Array
) – Array of ending pointsweight (
Union
[Array
,float
]) – Weight for the interpolation formula , array or scalar.out (
Optional
[Array
]) – Alternate output array in which to place the result. (default:None
) The default is None.
- Return type:
Array
- Returns:
ret – The linear interpolation between array self and array end based on scalar or array weight self + ((end - self) * weight)
Examples
>>> x = ivy.array([1.0, 2.0, 3.0, 4.0]) >>> end = ivy.array([10.0, 10.0, 10.0, 10.0]) >>> weight = 0.5 >>> x.lerp(end, weight) ivy.array([5.5, 6. , 6.5, 7. ])
- logaddexp2(x2, /, *, out=None)[source]#
ivy.Array instance method variant of ivy.logaddexp2. This method simply wraps the function, and so the docstring for ivy.logaddexp2 also applies to this method with minimal changes.
- Parameters:
self (
Union
[Array
,float
,list
,tuple
]) – First array-like input.x2 (
Union
[Array
,float
,list
,tuple
]) – Second array-like inputout (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – Element-wise logaddexp2 of x1 and x2.
Examples
>>> x1 = ivy.array([1, 2, 3]) >>> x2 = ivy.array([4, 5, 6]) >>> x1.logaddexp2(x2) ivy.array([4.169925, 5.169925, 6.169925])
- nan_to_num(*, copy=True, nan=0.0, posinf=None, neginf=None, out=None)[source]#
ivy.Array instance method variant of ivy.nan_to_num. This method simply wraps the function, and so the docstring for ivy.nan_to_num also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Array input.copy (
bool
) – Whether to create a copy of x (True) or to replace values in-place (False). (default:True
) The in-place operation only occurs if casting to an array does not require a copy. Default is True.nan (
Union
[float
,int
]) – Value to be used to fill NaN values. If no value is passed then NaN values (default:0.0
) will be replaced with 0.0.posinf (
Optional
[Union
[int
,float
]]) – Value to be used to fill positive infinity values. If no value is passed (default:None
) then positive infinity values will be replaced with a very large number.neginf (
Optional
[Union
[int
,float
]]) – Value to be used to fill negative infinity values. (default:None
) If no value is passed then negative infinity values will be replaced with a very small (or negative) number.out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – Array with the non-finite values replaced. If copy is False, this may be x itself.
Examples
>>> x = ivy.array([1, 2, 3, nan]) >>> x.nan_to_num() ivy.array([1., 1., 3., 0.0]) >>> x = ivy.array([1, 2, 3, inf]) >>> x.nan_to_num(posinf=5e+100) ivy.array([1., 2., 3., 5e+100])
- nansum(*, axis=None, dtype=None, keepdims=False, out=None)[source]#
ivy.Array instance method variant of ivy.nansum. This method simply wraps the function, and so the docstring for ivy.nansum also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array.axis (
Optional
[Union
[tuple
,int
]]) – Axis or axes along which the sum is computed. (default:None
) The default is to compute the sum of the flattened array.dtype (
Optional
[Union
[Dtype
,NativeDtype
]]) – The type of the returned array and of the accumulator in (default:None
) which the elements are summed. By default, the dtype of input is used.keepdims (
bool
) – If this is set to True, the axes which are reduced are left (default:False
) in the result as dimensions with size one.out (
Optional
[Container
]) – Alternate output array in which to place the result. (default:None
) The default is None.
- Return type:
Array
- Returns:
ret – A new array holding the result is returned unless out is specified, in which it is returned.
Examples
>>> a = ivy.array([[ 2.1, 3.4, ivy.nan], [ivy.nan, 2.4, 2.1]]) >>> ivy.nansum(a) 10.0 >>> ivy.nansum(a, axis=0) ivy.array([2.1, 5.8, 2.1]) >>> ivy.nansum(a, axis=1) ivy.array([5.5, 4.5])
- nextafter(x2, /, *, out=None)[source]#
ivy.Array instance method variant of ivy.nextafter. This method simply wraps the function, and so the docstring for ivy.nextafter also applies to this method with minimal changes.
- Parameters:
self (
Array
) – First input array.x2 (
Array
) – Second input array.out (
Optional
[Array
]) – Alternate output array in which to place the result. (default:None
) The default is None.
- Return type:
Array
- Returns:
ret – The next representable values of x1 in the direction of x2.
Examples
>>> x1 = ivy.array([1.0e-50, 2.0e+50]) >>> x2 = ivy.array([2.0, 1.0]) >>> x1.nextafter(x2) ivy.array([1.4013e-45., 3.4028e+38])
- real(*, out=None)[source]#
ivy.Array instance method variant of ivy.real. This method simply wraps the function, and so the docstring for ivy.real also applies to this method with minimal changes.
- Parameters:
self (
Array
) – input array. Should have a real-valued floating-point data type.out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
) It must have a shape that the inputs broadcast to.
- Return type:
Array
- Returns:
ret – an array containing test results. If input in an array is real then, it is returned unchanged. on the other hand, if it is complex then, it returns real part from it
Examples
>>> x = ivy.array([4+3j, 6+2j, 1-6j]) >>> x.real() ivy.array([4., 6., 1.])
- signbit(*, out=None)[source]#
ivy.Array instance method variant of ivy.signbit. This method simply wraps the function, and so the docstring for ivy.signbit also applies to this method with minimal changes.
- Parameters:
self (
Union
[Array
,float
,int
,list
,tuple
]) – Array-like input.out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – Element-wise signbit of x.
Examples
>>> x = ivy.array([1, -2, 3]) >>> x.signbit() ivy.array([False, True, False])
- sinc(*, out=None)[source]#
ivy.Array instance method variant of ivy.sinc. This method simply wraps the function, and so the docstring for ivy.sinc also applies to this method with minimal changes.
- Parameters:
self (
Array
) – input array whose elements are each expressed in radians. Should have a floating-point data type.out (
Optional
[Array
]) – optional output array, for writing the result to. It must have a shape that (default:None
) the inputs broadcast to.
- Return type:
Array
- Returns:
ret – an array containing the sinc of each element in
self
. The returned array must have a floating-point data type determined by type-promotion.
Examples
>>> x = ivy.array([0.5, 1.5, 2.5, 3.5]) >>> y = x.sinc() >>> print(y) ivy.array([0.637,-0.212,0.127,-0.0909])
- xlogy(y, /, *, out=None)[source]#
ivy.Array instance method variant of ivy.xlogy. This method simply wraps the function, and so the docstring for ivy.xlogy also applies to this method with minimal changes.
- Parameters:
self (
Array
) – First input array.y (
Array
) – Second input array.out (
Optional
[Array
]) – Alternate output array in which to place the result. (default:None
) The default is None.
- Return type:
Array
- Returns:
ret – The next representable values of x1 in the direction of x2.
Examples
>>> x = ivy.zeros(3) >>> y = ivy.array([-1.0, 0.0, 1.0]) >>> x.xlogy(y) ivy.array([0.0, 0.0, 0.0])
>>> x = ivy.array([1.0, 2.0, 3.0]) >>> y = ivy.array([3.0, 2.0, 1.0]) >>> x.xlogy(y) ivy.array([1.0986, 1.3863, 0.0000])
- zeta(q, /, *, out=None)[source]#
ivy.Array instance method variant of ivy.zeta. This method simply wraps the function, and so the docstring for ivy.zeta also applies to this method with minimal changes.
- Parameters:
self (
Array
) – First input array.q (
Array
) – Second input array.out (
Optional
[Array
]) – Alternate output array in which to place the result. (default:None
) The default is None.
- Return type:
Array
- Returns:
ret – Array with values computed from zeta function from input arrays’ values.
Examples
>>> x = ivy.array([5.0, 3.0]) >>> q = ivy.array([2.0]) >>> x.zeta(q) ivy.array([0.0369, 0.2021])
- class ivy.data_classes.array.experimental.general._ArrayWithGeneralExperimental[source]#
- _abc_impl = <_abc_data object>#
- class ivy.data_classes.array.experimental.gradients._ArrayWithGradientsExperimental[source]#
- _abc_impl = <_abc_data object>#
- class ivy.data_classes.array.experimental.image._ArrayWithImageExperimental[source]#
- _abc_impl = <_abc_data object>#
- class ivy.data_classes.array.experimental.layers._ArrayWithLayersExperimental[source]#
- _abc_impl = <_abc_data object>#
- adaptive_avg_pool1d(output_size)[source]#
Apply a 1D adaptive average pooling over an input signal composed of several input planes.
- Parameters:
self (
Array
) – Input array. Must have shape (N, C, L_in) or (C, L_in) where N is the batch dimension, C is the feature dimension, and L_in is the spatial dimension.output_size (
int
) – Spatial output size.
- Return type:
Array
- Returns:
The result of the pooling operation. Will have shape (N, C, L_out) or
(C, L_out), where L_out = output_size
- adaptive_avg_pool2d(output_size)[source]#
Apply a 2D adaptive average pooling over an input signal composed of several input planes.
- Parameters:
self (
Array
) – Input array. Must have shape (N, C, H_in, W_in) or (C, H_in, W_in) where N is the batch dimension, C is the feature dimension, and H_in and W_in are the 2 spatial dimensions.output_size (
Union
[Sequence
[int
],int
]) – Spatial output size.
- Return type:
Array
- Returns:
The result of the pooling operation. Will have shape (N, C, S_0, S_1) or
(C, S_0, S_1), where S = output_size
- avg_pool1d(kernel, strides, padding, /, *, data_format='NWC', count_include_pad=False, ceil_mode=False, out=None)[source]#
ivy.Array instance method variant of ivy.avg_pool1d. This method simply wraps the function, and so the docstring for ivy.avg_pool1d also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input image [batch_size,w,d_in].kernel (
Union
[int
,Tuple
[int
]]) – The size of the window for each dimension of the input tensor.strides (
Union
[int
,Tuple
[int
]]) – The stride of the sliding window for each dimension of input.padding (
str
) – “SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.data_format (
str
) – “NWC” or “NCW”. Defaults to “NWC”. (default:'NWC'
)count_include_pad (
bool
) – Whether to include padding in the averaging calculation. (default:False
)ceil_mode (
bool
) – Whether to use ceil or floor for creating the output shape. (default:False
)out (
Optional
[Array
]) – optional output array, for writing the result to. It must have a shape that (default:None
) the inputs broadcast to.
- Return type:
Array
- Returns:
ret – The result of the max pooling operation.
Examples
>>> x = ivy.arange(0, 24.).reshape((2, 3, 4)) >>> print(x.avg_pool1d(2, 2, 'SAME')) ivy.array([[[ 2., 3., 4., 5.], [ 8., 9., 10., 11.]], [[14., 15., 16., 17.], [20., 21., 22., 23.]]])
>>> x = ivy.arange(0, 24.).reshape((2, 3, 4)) >>> print(x.avg_pool1d(2, 2, 'VALID')) ivy.array([[[ 2., 3., 4., 5.]], [[14., 15., 16., 17.]]])
- avg_pool2d(kernel, strides, padding, /, *, data_format='NHWC', count_include_pad=False, ceil_mode=False, divisor_override=None, out=None)[source]#
ivy.Array instance method variant of ivy.avg_pool2d. This method simply wraps the function, and so the docstring for ivy.avg_pool2d also applies to this method with minimal changes.
- Parameters:
x – Input image [batch_size,h,w,d_in].
kernel (
Union
[int
,Tuple
[int
],Tuple
[int
,int
]]) – The size of the window for each dimension of the input tensor.strides (
Union
[int
,Tuple
[int
],Tuple
[int
,int
]]) – The stride of the sliding window for each dimension of input.padding (
str
) – “SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.data_format (
str
) – “NHWC” or “NCHW”. Defaults to “NHWC”. (default:'NHWC'
)count_include_pad (
bool
) – Whether to include padding in the averaging calculation. (default:False
)ceil_mode (
bool
) – Whether to use ceil or floor for creating the output shape. (default:False
)divisor_override (
Optional
[int
]) – If given, it will be used as the divisor, (default:None
) otherwise kernel_size will be used.out (
Optional
[Array
]) – optional output array, for writing the result to. It must have a shape that (default:None
) the inputs broadcast to.
- Return type:
Array
- Returns:
ret – The result of the max pooling operation.
Examples
>>> x = ivy.arange(12.).reshape((2, 1, 3, 2)) >>> print(x.max_pool2d((2, 2), (1, 1), 'SAME')) ivy.array([[[[ 2, 3], [ 4, 5], [ 4, 5]]], [[[ 8, 9], [10, 11], [10, 11]]]])
>>> x = ivy.arange(48.).reshape((2, 4, 3, 2)) >>> print(x.max_pool2d(3, 1, 'VALID')) ivy.array([[[[16, 17]], [[22, 23]]], [[[40, 41]], [[46, 47]]]])
- avg_pool3d(kernel, strides, padding, /, *, data_format='NDHWC', count_include_pad=False, ceil_mode=False, divisor_override=None, out=None)[source]#
Compute a 3-D max pool given 5-D input x.
- Parameters:
self (
Array
) – Input volume [batch_size,d,h,w,d_in].kernel (
Union
[int
,Tuple
[int
],Tuple
[int
,int
,int
]]) – Convolution filters [d,h,w].strides (
Union
[int
,Tuple
[int
],Tuple
[int
,int
,int
]]) – The stride of the sliding window for each dimension of input.padding (
str
) – SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.data_format (
str
) – NDHWC” or “NCDHW”. Defaults to “NDHWC”. (default:'NDHWC'
)count_include_pad (
bool
) – Whether to include padding in the averaging calculation. (default:False
)ceil_mode (
bool
) – Whether to use ceil or floor for creating the output shape. (default:False
)divisor_override (
Optional
[int
]) – If specified, it will be used as divisor, (default:None
) otherwise kernel_size will be used.out (
Optional
[Array
]) – optional output array, for writing the result to. It must have (default:None
) a shape that the inputs broadcast to.
- Return type:
Array
- Returns:
ret – The result of the pooling operation.
Examples
>>> x = ivy.arange(48.).reshape((2, 3, 2, 2, 2)) >>> print(x.avg_pool3d(2, 2, 'VALID')) ivy.array([[[[[ 7., 8.]]]], [[[[31., 32.]]]]]) >>> print(x.avg_pool3d(2, 2, 'SAME')) ivy.array([[[[[ 7., 8.]]], [[[19., 20.]]]], [[[[31., 32.]]], [[[43., 44.]]]]])
- dct(*, type=2, n=None, axis=-1, norm=None, out=None)[source]#
ivy.Array instance method variant of ivy.dct. This method simply wraps the function, and so the docstring for ivy.dct also applies to this method with minimal changes.
- Parameters:
self (
Array
) – The input signal.type (
Literal
[1, 2, 3, 4]) – The type of the dct. Must be 1, 2, 3 or 4. (default:2
)n (
Optional
[int
]) – The lenght of the transform. If n is less than the input signal lenght, (default:None
) then x is truncated, if n is larger than x is zero-padded.norm (
Optional
[Literal
[‘ortho’]]) – The type of normalization to be applied. Must be either None or “ortho”. (default:None
)out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – Array containing the transformed input.
Examples
>>> x = ivy.array([8., 16., 24., 32., 40., 48., 56., 64.]) >>> x.dct(type=2, norm="ortho") ivy.array([ 102., -51.5, 0., -5.39, 0., -1.61, 0., -0.406])
- dft(*, axis=1, inverse=False, onesided=False, dft_length=None, norm='backward', out=None)[source]#
Compute the discrete Fourier transform of input.
- Parameters:
self – Input volume […,d_in,…], where d_in indicates the dimension that needs FFT.
axis (
int
) – The axis on which to perform the DFT. By default this (default:1
) value is set to 1, which corresponds to the first dimension after the batch index.inverse (
bool
) – Whether to perform the inverse discrete fourier transform. (default:False
) By default this value is set to False.onesided (
bool
) – If onesided is True, only values for w in [0, 1, 2, …, floor(n_fft/2) + 1] (default:False
) are returned because the real-to-complex Fourier transform satisfies the conjugate symmetry, i.e., X[m, w] = X[m,w]=X[m,n_fft-w]*. Note if the input or window tensors are complex, then onesided output is not possible. Enabling onesided with real inputs performs a Real-valued fast Fourier transform (RFFT). When invoked with real or complex valued input, the default value is False. Values can be True or False.dft_length (
Optional
[Union
[int
,Tuple
[int
]]]) – The length of the signal.If greater than the axis dimension, (default:None
) the signal will be zero-padded up to dft_length. If less than the axis dimension, only the first dft_length values will be used as the signal. It’s an optional value.norm (
str
) – Optional argument, “backward”, “ortho” or “forward”. Defaults to be (default:'backward'
) “backward”. “backward” indicates no normalization. “ortho” indicates normalization by 1/sqrt(n). “forward” indicates normalization by 1/n.out (
Optional
[Array
]) – Optional output array, for writing the result to. It must (default:None
) have a shape that the inputs broadcast to.
- Return type:
Array
- Returns:
ret – The Fourier Transform of the input vector.If onesided is False, the following shape is expected: [batch_idx][signal_dim1][signal_dim2] …[signal_dimN][2]. If axis=0 and onesided is True, the following shape is expected: [batch_idx][floor(signal_dim1/2)+1][signal_dim2] …[signal_dimN][2]. If axis=1 and onesided is True, the following shape is expected: [batch_idx][signal_dim1] [floor(signal_dim2/2)+1] …[signal_dimN][2]. If axis=N-1 and onesided is True, the following shape is expected: [batch_idx][signal_dim1][signal_dim2]… [floor(signal_dimN/2)+1][2]. The signal_dim at the specified axis is equal to the dft_length.
- fft(dim, /, *, norm='backward', n=None, out=None)[source]#
ivy.Array instance method variant of ivy.ifft. This method simply wraps the function, and so the docstring for ivy.ifft also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input volume […,d_in,…], where d_in indicates the dimension that needs FFT.dim (
int
) – The dimension along which to take the one dimensional FFT.norm (
str
) – Optional argument, “backward”, “ortho” or “forward”. Defaults to be (default:'backward'
) “backward”. “backward” indicates no normalization. “ortho” indicates normalization by 1/sqrt(n). “forward” indicates normalization by 1/n.n (
Optional
[Union
[int
,Tuple
[int
]]]) – Optional argument indicating the sequence length, if given, the input (default:None
) would be padded with zero or truncated to length n before performing FFT. Should be a integer greater than 1.out (
Optional
[Array
]) – Optional output array, for writing the result to. It must have a shape (default:None
) that the inputs broadcast to.
- Return type:
Array
- Returns:
ret – Array containing the transformed input.
Examples
>>> a = ivy.array((np.exp(2j * np.pi * np.arange(8) / 8))) >>> a.fft(0) ivy.array([-3.44509285e-16+1.14423775e-17j, 8.00000000e+00-8.11483250e-16j, 2.33486982e-16+1.22464680e-16j, 0.00000000e+00+1.22464680e-16j, 9.95799250e-17+2.33486982e-16j, 0.00000000e+00+7.66951701e-17j, 1.14423775e-17+1.22464680e-16j, 0.00000000e+00+1.22464680e-16j])
- ifft(dim, *, norm='backward', n=None, out=None)[source]#
ivy.Array instance method variant of ivy.ifft. This method simply wraps the function, and so the docstring for ivy.ifft also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input volume […,d_in,…], where d_in indicates the dimension that needs IFFT.dim (
int
) – The dimension along which to take the one dimensional IFFT.norm (
str
) – Optional argument, “backward”, “ortho” or “forward”. Defaults to be (default:'backward'
) “backward”. “backward” indicates no normalization. “ortho” indicates normalization by 1/sqrt(n). “forward” indicates normalization by 1/n.n (
Optional
[Union
[int
,Tuple
[int
]]]) – Optional argument indicating the sequence length, if given, the input (default:None
) would be padded with zero or truncated to length n before performing IFFT. Should be a integer greater than 1.out (
Optional
[Array
]) – Optional output array, for writing the result to. It must have a shape that (default:None
) the inputs broadcast to.
- Return type:
Array
- Returns:
ret – Array containing the transformed input.
Examples
>>> a = ivy.array((np.exp(2j * np.pi * np.arange(8) / 8))) >>> a.ifft(0) ivy.array([-4.30636606e-17+1.43029718e-18j, 0.00000000e+00+1.53080850e-17j, 1.43029718e-18+1.53080850e-17j, 0.00000000e+00+9.58689626e-18j, 1.24474906e-17+2.91858728e-17j, 0.00000000e+00+1.53080850e-17j, 2.91858728e-17+1.53080850e-17j, 1.00000000e+00-1.01435406e-16j])
- interpolate(size, /, *, mode='linear', scale_factor=None, recompute_scale_factor=None, align_corners=None, antialias=False, out=None)[source]#
Down/up samples the input to the given size. The algorithm used for interpolation is determined by mode.
- Parameters:
self – Input array, Must have the shape [batch x channels x [optional depth] x [optional height] x width].
size (
Union
[Sequence
[int
],int
]) – Output size.mode (
Literal
[‘linear’, ‘bilinear’, ‘trilinear’, ‘nearest’, ‘area’, ‘nearest_exact’, ‘tf_area’, ‘bicubic’]) – Interpolation mode. Can be one of the following: (default:'linear'
) - linear - bilinear - trilinear - nearest - area - tf_area - bicubic - mitchellcubic - lanczos3 - lanczos5 - gaussianscale_factor (
Optional
[Union
[int
,Sequence
[int
]]]) – Multiplier for spatial size that defines the output size (default:None
) (overwriting size).align_corners (
Optional
[bool
]) – If True, the corner pixels of the input and output tensors are aligned, (default:None
) and thus preserving the values at the corner pixels. If False, the corner pixels are not aligned, and the interpolation uses edge value padding for out-of-boundary values. only has an effect when mode is ‘linear’, ‘bilinear’, ‘bicubic’ or ‘trilinear’. Default: Falseantialias (
bool
) – If True, antialiasing is applied when downsampling an image. (default:False
) Supported modes: ‘bilinear’, ‘bicubic’.out (
Optional
[Array
]) – Optional output array, for writing the result to. It must (default:None
) have a shape that the inputs broadcast to.
- Return type:
Array
- Returns:
resized array
- max_pool1d(kernel, strides, padding, /, *, data_format='NWC', out=None)[source]#
ivy.Array instance method variant of ivy.max_pool1d. This method simply wraps the function, and so the docstring for ivy.max_pool1d also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input image [batch_size,w,d_in].kernel (
Union
[int
,Tuple
[int
]]) – The size of the window for each dimension of the input tensor.strides (
Union
[int
,Tuple
[int
]]) – The stride of the sliding window for each dimension of input.padding (
str
) – “SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.data_format (
str
) – “NWC” or “NCW”. Defaults to “NWC”. (default:'NWC'
)out (
Optional
[Array
]) – optional output array, for writing the result to. It must have a shape that (default:None
) the inputs broadcast to.
- Return type:
Array
- Returns:
ret – The result of the max pooling operation.
Examples
>>> x = ivy.arange(0, 24.).reshape((2, 3, 4)) >>> print(x.max_pool1d(2, 2, 'SAME')) ivy.array([[[ 4., 5., 6., 7.], [ 8., 9., 10., 11.]], [[16., 17., 18., 19.], [20., 21., 22., 23.]]]) >>> x = ivy.arange(0, 24.).reshape((2, 3, 4)) >>> print(x.max_pool1d(2, 2, 'VALID')) ivy.array([[[ 4., 5., 6., 7.]], [[16., 17., 18., 19.]]])
- max_pool2d(kernel, strides, padding, /, *, data_format='NHWC', dilation=1, ceil_mode=False, out=None)[source]#
ivy.Array instance method variant of ivy.max_pool2d. This method simply wraps the function, and so the docstring for ivy.max_pool2d also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input image [batch_size,h,w,d_in].kernel (
Union
[int
,Tuple
[int
],Tuple
[int
,int
]]) – The size of the window for each dimension of the input tensor.strides (
Union
[int
,Tuple
[int
],Tuple
[int
,int
]]) – The stride of the sliding window for each dimension of input.padding (
str
) – “SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.data_format (
str
) – “NHWC” or “NCHW”. Defaults to “NHWC”. (default:'NHWC'
)out (
Optional
[Array
]) – optional output array, for writing the result to. It must have a shape that (default:None
) the inputs broadcast to.
- Return type:
Array
- Returns:
ret – The result of the max pooling operation.
Examples
>>> x = ivy.arange(12.).reshape((2, 1, 3, 2)) >>> print(x.max_pool2d((2, 2), (1, 1), 'SAME')) ivy.array([[[[ 2, 3], [ 4, 5], [ 4, 5]]], [[[ 8, 9], [10, 11], [10, 11]]]])
>>> x = ivy.arange(48.).reshape((2, 4, 3, 2)) >>> print(x.max_pool2d(3, 1, 'VALID')) ivy.array([[[[16, 17]], [[22, 23]]], [[[40, 41]], [[46, 47]]]])
- max_pool3d(kernel, strides, padding, /, *, data_format='NDHWC', out=None)[source]#
Compute a 3-D max pool given 5-D input x.
- Parameters:
self (
Array
) – Input volume [batch_size,d,h,w,d_in].kernel (
Union
[int
,Tuple
[int
],Tuple
[int
,int
,int
]]) – Convolution filters [d,h,w].strides (
Union
[int
,Tuple
[int
],Tuple
[int
,int
,int
]]) – The stride of the sliding window for each dimension of input.padding (
str
) – SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.data_format (
str
) – NDHWC” or “NCDHW”. Defaults to “NDHWC”. (default:'NDHWC'
)out (
Optional
[Array
]) – optional output array, for writing the result to. It must have (default:None
) a shape that the inputs broadcast to.
- Return type:
Array
- Returns:
ret – The result of the pooling operation.
Examples
>>> x = ivy.arange(48.).reshape((2, 3, 2, 2, 2)) >>> print(x.max_pool3d(2, 2, 'VALID')) ivy.array([[[[[14., 15.]]]], [[[[38., 39.]]]]]) >>> print(x.max_pool3d(2, 2, 'SAME')) ivy.array([[[[[14., 15.]]], [[[22., 23.]]]], [[[[38., 39.]]], [[[46., 47.]]]]])
- class ivy.data_classes.array.experimental.linear_algebra._ArrayWithLinearAlgebraExperimental[source]#
- _abc_impl = <_abc_data object>#
- adjoint(*, out=None)[source]#
ivy.Array instance method variant of ivy.adjoint. This method simply wraps the function, and so the docstring for ivy.adjoint also applies to this method with minimal changes.
Examples
>>> x = np.array([[1.-1.j, 2.+2.j], [3.+3.j, 4.-4.j]]) >>> x = ivy.array(x) >>> x.adjoint() ivy.array([[1.+1.j, 3.-3.j], [2.-2.j, 4.+4.j]])
- Return type:
Array
- cond(*, p=None)[source]#
ivy.Array instance method variant of ivy.cond. This method simply wraps the function, and so the docstring for ivy.cond also applies to this method with minimal changes.
Examples
>>> x = ivy.array([[1,2], [3,4]]) >>> x.cond() ivy.array(14.933034373659268)
>>> x = ivy.array([[1,2], [3,4]]) >>> x.cond(p=ivy.inf) ivy.array(21.0)
- Return type:
Array
- cov(x2=None, /, *, rowVar=True, bias=False, ddof=None, fweights=None, aweights=None, dtype=None)[source]#
ivy.Array instance method variant of ivy.cov. This method simply wraps the function, and so the docstring for ivy.cov also applies to this method with minimal changes.
- Parameters:
self (
Array
) – a 1D or 2D input array, with a numeric data type.x2 (
Optional
[Union
[Array
,NativeArray
]]) – optional second 1D or 2D input array, with a numeric data type. (default:None
) Must have the same shape asself
.rowVar (
bool
) – optional variable where each row of input is interpreted as a variable (default:True
) (default = True). If set to False, each column is instead interpreted as a variable.bias (
bool
) – optional variable for normalizing input (default = False) by (N - 1) where (default:False
) N is the number of given observations. If set to True, then normalization is instead by N. Can be overridden by keywordddof
.ddof (
Optional
[int
]) – optional variable to overridebias
(default = None). ddof=1 will return (default:None
) the unbiased estimate, even with fweights and aweights given. ddof=0 will return the simple average.fweights (
Optional
[Array
]) – optional 1D array of integer frequency weights; the number of times each (default:None
) observation vector should be repeated.aweights (
Optional
[Array
]) – optional 1D array of observation vector weights. These relative weights are (default:None
) typically large for observations considered “important” and smaller for observations considered less “important”. If ddof=0 is specified, the array of weights can be used to assign probabilities to observation vectors.dtype (
Optional
[type
]) – optional variable to set data-type of the result. By default, data-type (default:None
) will have at leastfloat64
precision.out – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.
- Return type:
Array
- Returns:
ret – an array containing the covariance matrix of an input matrix, or the covariance matrix of two variables. The returned array must have a floating-point data type determined by Type Promotion Rules and must be a square matrix of shape (N, N), where N is the number of variables in the input(s).
Examples
>>> x = ivy.array([[1,2,3], ... [4,5,6]]) >>> y = x.cov() >>> print(y) ivy.array([[ 1., 1. ], ... [ 1., 1. ], >>> x = ivy.array([1,2,3]) >>> y = ivy.array([4,5,6]) >>> z = x.cov(y) >>> print(z) ivy.array([[ 1., 1. ], ... [ 1., 1. ])
- diagflat(*, offset=0, padding_value=0, align='RIGHT_LEFT', num_rows=-1, num_cols=-1, out=None)[source]#
ivy.Array instance method variant of ivy.diagflat. This method simply wraps the function, and so the docstring for ivy.diagflat also applies to this method with minimal changes.
Examples
>>> x = ivy.array([1,2]) >>> x.diagflat(k=1) ivy.array([[0, 1, 0], [0, 0, 2], [0, 0, 0]])
- Return type:
Array
- eig()[source]#
ivy.Array instance method variant of ivy.eig. This method simply wraps the function, and so the docstring for ivy.eig also applies to this method with minimal changes.
Examples
>>> x = ivy.array([[1,2], [3,4]]) >>> x.eig() ( ivy.array([-0.37228132+0.j, 5.37228132+0.j]), ivy.array([[-0.82456484+0.j, -0.41597356+0.j], [ 0.56576746+0.j, -0.90937671+0.j]]) )
- Return type:
Tuple
[Array
,...
]
- eigh_tridiagonal(beta, /, *, eigvals_only=True, select='a', select_range=None, tol=None)[source]#
ivy.Array instance method variant of ivy.eigh_tridiagonal. This method simply wraps the function, and so the docstring for ivy.eigh_tridiagonal also applies to this method with minimal changes.
- Parameters:
self (
Union
[Array
,NativeArray
]) – An array of real or complex arrays each of shape (n), the diagonal elements of the matrix.beta (
Union
[Array
,NativeArray
]) – An array or of real or complex arrays each of shape (n-1), containing the elements of the first super-diagonal of the matrix.eigvals_only (
bool
) – If False, both eigenvalues and corresponding eigenvectors are computed. (default:True
) If True, only eigenvalues are computed. Default is True.select (
str
) – Optional string with values in {‘a’, ‘v’, ‘i’} (default:'a'
) (default is ‘a’) that determines which eigenvalues to calculate: ‘a’: all eigenvalues. ‘v’: eigenvalues in the interval (min, max] given by select_range. ‘i’: eigenvalues with indices min <= i <= max.select_range (
Optional
[Union
[Tuple
[int
,int
],List
[int
],Array
,NativeArray
]]) – Size 2 tuple or list or array specifying the range of (default:None
) eigenvalues to compute together with select. If select is ‘a’, select_range is ignored.tol (
Optional
[float
]) – Optional scalar. Ignored when backend is not Tensorflow. The (default:None
) absolute tolerance to which each eigenvalue is required. An eigenvalue (or cluster) is considered to have converged if it lies in an interval of this width. If tol is None (default), the value eps*|T|_2 is used where eps is the machine precision, and |T|_2 is the 2-norm of the matrix T.
- Return type:
Union
[Array
,Tuple
[Array
,Array
]]- Returns:
eig_vals – The eigenvalues of the matrix in non-decreasing order.
eig_vectors – If eigvals_only is False the eigenvectors are returned in the second output argument.
Examples
>>> alpha = ivy.array([0., 1., 2.]) >>> beta = ivy.array([0., 1.]) >>> y = alpha.eigh_tridiagonal(beta) >>> print(y) ivy.array([0., 0.38196, 2.61803])
- eigvals()[source]#
ivy.Array instance method variant of ivy.eigvals. This method simply wraps the function, and so the docstring for ivy.eigvals also applies to this method with minimal changes.
Examples
>>> x = ivy.array([[1,2], [3,4]]) >>> x.eigvals() ivy.array([-0.37228132+0.j, 5.37228132+0.j])
- Return type:
Array
- kron(b, /, *, out=None)[source]#
ivy.Array instance method variant of ivy.kron. This method simply wraps the function, and so the docstring for ivy.kron also applies to this method with minimal changes.
Examples
>>> a = ivy.array([1,2]) >>> b = ivy.array([3,4]) >>> a.diagflat(b) ivy.array([3, 4, 6, 8])
- Return type:
Array
- matrix_exp(*, out=None)[source]#
ivy.Array instance method variant of ivy.kron. This method simply wraps the function, and so the docstring for ivy.matrix_exp also applies to this method with minimal changes.
Examples
>>> x = ivy.array([[[1., 0.], [0., 1.]], [[2., 0.], [0., 2.]]]) >>> ivy.matrix_exp(x) ivy.array([[[2.7183, 1.0000], [1.0000, 2.7183]], [[7.3891, 1.0000], [1.0000, 7.3891]]])
- Return type:
Array
- multi_dot(x, /, *, out=None)[source]#
ivy.Array instance method variant of ivy.multi_dot. This method simply wraps the function, and so the docstring for ivy.multi_dot also applies to this method with minimal changes.
Examples
>>> A = ivy.arange(2 * 3).reshape((2, 3)) >>> B = ivy.arange(3 * 2).reshape((3, 2)) >>> C = ivy.arange(2 * 2).reshape((2, 2)) >>> A.multi_dot((B, C)) ivy.array([[ 26, 49], [ 80, 148]])
- Return type:
Array
- class ivy.data_classes.array.experimental.losses._ArrayWithLossesExperimental[source]#
- _abc_impl = <_abc_data object>#
- class ivy.data_classes.array.experimental.manipulation._ArrayWithManipulationExperimental[source]#
- _abc_impl = <_abc_data object>#
- as_strided(shape, strides, /)[source]#
Create a copy of the input array with the given shape and strides.
- Parameters:
self (
Array
) – Input Array.shape (
Union
[Shape
,NativeShape
,Sequence
[int
]]) – The shape of the new array.strides (
Sequence
[int
]) – The strides of the new array (specified in bytes).
- Return type:
Array
- Returns:
ret – Output Array
- associative_scan(fn, /, *, reverse=False, axis=0)[source]#
Perform an associative scan over the given array.
- Parameters:
self (
Array
) – The array to scan over.fn (
Callable
) – The associative function to apply.reverse (
bool
) – Whether to scan in reverse with respect to the given axis. (default:False
)axis (
int
) – The axis to scan over. (default:0
)
- Return type:
Array
- Returns:
ret – The result of the scan.
- atleast_1d(*arys, copy=None)[source]#
ivy.Array instance method variant of ivy.atleast_1d. This method simply wraps the function, and so the docstring for ivy.atleast_1d also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array. Cannot be a scalar input.arys (
Union
[Array
,bool
,Number
]) – An arbitrary number of input arrays.
- Return type:
List
[Array
]- Returns:
ret – List of arrays, each with a.ndim >= 1. Copies are made only if necessary.
Examples
>>> a1 = ivy.array([[1,2,3]]) >>> a2 = ivy.array(4) >>> a1.atleast_1d(a2,5,6) [ivy.array([[1, 2, 3]]), ivy.array([4]), ivy.array([5]), ivy.array([6])]
- atleast_2d(*arys, copy=None)[source]#
ivy.Array instance method variant of ivy.atleast_2d. This method simply wraps the function, and so the docstring for ivy.atleast_2d also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array. Cannot be a scalar input.arys (
Array
) – An arbitrary number of input arrays.
- Return type:
List
[Array
]- Returns:
ret – List of arrays, each with a.ndim >= 2. Copies are made only if necessary.
Examples
>>> a1 = ivy.array([[1,2,3]]) >>> a2 = ivy.array(4) >>> a1.atleast_2d(a2,5,6) [ivy.array([[1, 2, 3]]), ivy.array([[4]]), ivy.array([[5]]), ivy.array([[6]])]
- atleast_3d(*arys, copy=None)[source]#
ivy.Array instance method variant of ivy.atleast_3d. This method simply wraps the function, and so the docstring for ivy.atleast_3d also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array. Cannot be a scalar input.arys (
Union
[Array
,bool
,Number
]) – An arbitrary number of input arrays.
- Return type:
List
[Array
]- Returns:
ret – List of arrays, each with a.ndim >= 3. Copies are made only if necessary and views with three or more dimensions are returned. For example, a 1-D array of shape (N,) becomes a view of shape (1, N, 1), and a 2-D array of shape (M, N) becomes a view of shape (M, N, 1).
Examples
>>> a1 = ivy.array([[1,2,3]]) >>> a2 = ivy.array([4,8]) >>> a1.atleast_3d(a2,5,6) [ivy.array([[[1], [2], [3]]]), ivy.array([[[4], [8]]]), ivy.array([[[5]]]), ivy.array([[[6]]])]
- concat_from_sequence(input_sequence, *, new_axis=0, axis=0, out=None)[source]#
Concatenate a sequence of arrays along a new or an existing axis.
- Parameters:
self (
Array
) – Array input.input_sequence (
Union
[Tuple
[Union
[Array
,NativeArray
]],List
[Union
[Array
,NativeArray
]]]) – A sequence of arrays.new_axis (
int
) – Insert and concatenate on a new axis or not, (default:0
) default 0 means do not insert new axis. new_axis = 0: concatenate new_axis = 1: stackaxis (
int
) – The axis along which the arrays will be concatenated. (default:0
)out (
Optional
[Array
]) – Optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – Output Array
- dsplit(indices_or_sections, /, *, copy=None)[source]#
ivy.Array instance method variant of ivy.dsplit. This method simply wraps the function, and so the docstring for ivy.dsplit also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array.indices_or_sections (
Union
[int
,Sequence
[int
],Array
]) – If indices_or_sections is an integer n, the array is split into n equal sections, provided that n must be a divisor of the split axis. If indices_or_sections is a sequence of ints or 1-D array, then input is split at each of the indices.
- Return type:
List
[Array
]- Returns:
ret – input array split along the 3rd axis.
Examples
>>> ary = ivy.array( [[[ 0., 1., 2., 3.], [ 4., 5., 6., 7.]], [[ 8., 9., 10., 11.], [12., 13., 14., 15.]]] ) >>> ary.dsplit(2) [ivy.array([[[ 0., 1.], [ 4., 5.]], [[ 8., 9.], [12., 13.]]]), ivy.array([[[ 2., 3.], [ 6., 7.]], [[10., 11.], [14., 15.]]])]
- dstack(arrays, /, *, out=None)[source]#
ivy.Array instance method variant of ivy.dstack. This method simply wraps the function, and so the docstring for ivy.dstack also applies to this method with minimal changes.
Examples
>>> x = ivy.array([1, 2, 3]) >>> y = ivy.array([2, 3, 4]) >>> x.dstack(y) ivy.array([[[1, 2], [2, 3], [3, 4]]])
- Return type:
Array
- expand(shape, /, *, copy=None, out=None)[source]#
Broadcast the input Array following the given shape and the broadcast rule.
- Parameters:
self (
Array
) – Array input.shape (
Union
[Shape
,NativeShape
]) – A 1-D Array indicates the shape you want to expand to, following the broadcast ruleout (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – Output Array
- flatten(*, copy=None, start_dim=0, end_dim=-1, order='C', out=None)[source]#
ivy.Array instance method variant of ivy.flatten. This method simply wraps the function, and so the docstring for ivy.flatten also applies to this method with minimal changes.
- Parameters:
self (
Array
) – input array to flatten.start_dim (
int
) – first dim to flatten. If not set, defaults to 0. (default:0
)end_dim (
int
) – last dim to flatten. If not set, defaults to -1. (default:-1
)order (
str
) – Read the elements of the input container using this index order, (default:'C'
) and place the elements into the reshaped array using this index order. ‘C’ means to read / write the elements using C-like index order, with the last axis index changing fastest, back to the first axis index changing slowest. ‘F’ means to read / write the elements using Fortran-like index order, with the first index changing fastest, and the last index changing slowest. Note that the ‘C’ and ‘F’ options take no account of the memory layout of the underlying array, and only refer to the order of indexing. Default order is ‘C’.out (
Optional
[Array
]) – Optional output, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – the flattened array over the specified dimensions.
Examples
>>> x = ivy.array([[1,2], [3,4]]) >>> x.flatten() ivy.array([1, 2, 3, 4])
>>> x = ivy.array([[1,2], [3,4]]) >>> x.flatten(order='F') ivy.array([1, 3, 2, 4])
>>> x = ivy.array( [[[[ 5, 5, 0, 6], [17, 15, 11, 16], [ 6, 3, 13, 12]],
[[ 6, 18, 10, 4], [ 5, 1, 17, 3], [14, 14, 18, 6]]],
- [[[12, 0, 1, 13],
[ 8, 7, 0, 3], [19, 12, 6, 17]],
[[ 4, 15, 6, 15], [ 0, 5, 17, 9], [ 9, 3, 6, 19]]],
- [[[17, 13, 11, 16],
[ 4, 18, 17, 4], [10, 10, 9, 1]],
[[19, 17, 13, 10], [ 4, 19, 16, 17], [ 2, 12, 8, 14]]]] )
>>> x.flatten(start_dim = 1, end_dim = 2) ivy.array( [[[ 5, 5, 0, 6], [17, 15, 11, 16], [ 6, 3, 13, 12], [ 6, 18, 10, 4], [ 5, 1, 17, 3], [14, 14, 18, 6]],
[[12, 0, 1, 13], [ 8, 7, 0, 3], [19, 12, 6, 17], [ 4, 15, 6, 15], [ 0, 5, 17, 9], [ 9, 3, 6, 19]],
[[17, 13, 11, 16], [ 4, 18, 17, 4], [10, 10, 9, 1], [19, 17, 13, 10], [ 4, 19, 16, 17], [ 2, 12, 8, 14]]]))
- fliplr(*, copy=None, out=None)[source]#
ivy.Array instance method variant of ivy.fliplr. This method simply wraps the function, and so the docstring for ivy.fliplr also applies to this method with minimal changes.
- Parameters:
self (
Array
) – The array to be flipped. Must be at least 2-D.out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – Array corresponding to input array with elements order reversed along axis 1.
Examples
>>> m = ivy.diag([1, 2, 3]) >>> m.fliplr() ivy.array([[0, 0, 1], [0, 2, 0], [3, 0, 0]])
- flipud(*, copy=None, out=None)[source]#
ivy.Array instance method variant of ivy.flipud. This method simply wraps the function, and so the docstring for ivy.flipud also applies to this method with minimal changes.
- Parameters:
self (
Array
) – The array to be flipped.out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – Array corresponding to input array with elements order reversed along axis 0.
Examples
>>> m = ivy.diag([1, 2, 3]) >>> m.flipud() ivy.array([[ 0., 0., 3.], [ 0., 2., 0.], [ 1., 0., 0.]])
- heaviside(x2, /, *, out=None)[source]#
ivy.Array instance method variant of ivy.heaviside. This method simply wraps the function, and so the docstring for ivy.heaviside also applies to this method with minimal changes.
- Parameters:
self (
Array
) – input array.x2 (
Array
) – values to use where x1 is zero.out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – output array with element-wise Heaviside step function of x1. This is a scalar if both x1 and x2 are scalars.
Examples
>>> x1 = ivy.array([-1.5, 0, 2.0]) >>> x2 = ivy.array([0.5]) >>> ivy.heaviside(x1, x2) ivy.array([0.0000, 0.5000, 1.0000])
>>> x1 = ivy.array([-1.5, 0, 2.0]) >>> x2 = ivy.array([1.2, -2.0, 3.5]) >>> ivy.heaviside(x1, x2) ivy.array([0., -2., 1.])
- hsplit(indices_or_sections, /, *, copy=None)[source]#
ivy.Array instance method variant of ivy.hsplit. This method simply wraps the function, and so the docstring for ivy.hsplit also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array.indices_or_sections (
Union
[int
,Tuple
[int
,...
]]) – If indices_or_sections is an integer n, the array is split into n equal sections, provided that n must be a divisor of the split axis. If indices_or_sections is a sequence of ints or 1-D array, then input is split at each of the indices.
- Return type:
List
[Array
]- Returns:
ret – list of arrays split horizontally from input array.
Examples
>>> ary = ivy.array( [[0., 1., 2., 3.], [4., 5., 6, 7.], [8., 9., 10., 11.], [12., 13., 14., 15.]] ) >>> ary.hsplit(2) [ivy.array([[ 0., 1.], [ 4., 5.], [ 8., 9.], [12., 13.]]), ivy.array([[ 2., 3.], [ 6., 7.], [10., 11.], [14., 15.]]))
- hstack(arrays, /, *, out=None)[source]#
ivy.Array instance method variant of ivy.hstack. This method simply wraps the function, and so the docstring for ivy.hstack also applies to this method with minimal changes.
Examples
>>> x = ivy.array([[1, 2]]) >>> y = [ivy.array([[5, 6]]), ivy.array([[7, 8]])] >>> print(x.vstack(y)) ivy.array([1, 2, 5, 6, 7, 8])
- Return type:
Array
- i0(*, out=None)[source]#
ivy.Array instance method variant of ivy.i0. This method simply wraps the function, and so the docstring for ivy.i0 also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array.out (
Optional
[Array
]) – Optional output, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – Array with modified Bessel function of the first kind, order 0.
Examples
>>> x = ivy.array([[1, 2, 3]]) >>> x.i0() ivy.array([1.26606588, 2.2795853 , 4.88079259])
- moveaxis(source, destination, /, *, copy=None, out=None)[source]#
ivy.Array instance method variant of ivy.moveaxis. This method simply wraps the function, and so the docstring for ivy.unstack also applies to this method with minimal changes.
- Parameters:
a – The array whose axes should be reordered.
source (
Union
[int
,Sequence
[int
]]) – Original positions of the axes to move. These must be unique.destination (
Union
[int
,Sequence
[int
]]) – Destination positions for each of the original axes. These must also be unique.out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – Array with moved axes. This array is a view of the input array.
Examples
>>> x = ivy.zeros((3, 4, 5)) >>> x.moveaxis(0, -1).shape (4, 5, 3) >>> x.moveaxis(-1, 0).shape (5, 3, 4)
- pad(pad_width, /, *, mode='constant', stat_length=1, constant_values=0, end_values=0, reflect_type='even', out=None, **kwargs)[source]#
ivy.Array instance method variant of ivy.pad.
This method simply wraps the function, and so the docstring for ivy.pad also applies to this method with minimal changes.
- Return type:
Array
- rot90(*, copy=None, k=1, axes=(0, 1), out=None)[source]#
ivy.Array instance method variant of ivy.rot90. This method simply wraps the function, and so the docstring for ivy.rot90 also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array of two or more dimensions.k (
int
) – Number of times the array is rotated by 90 degrees. (default:1
)axes (
Tuple
[int
,int
]) – The array is rotated in the plane defined by the axes. Axes must be (default:(0, 1)
) different.out (
Optional
[Array
]) – Optional output, for writing the result to. It must have a shape that the (default:None
) inputs broadcast to.
- Return type:
Array
- Returns:
ret – Array with a rotated view of input array.
Examples
>>> m = ivy.array([[1,2], [3,4]]) >>> m.rot90() ivy.array([[2, 4], [1, 3]]) >>> m = ivy.array([[1,2], [3,4]]) >>> m.rot90(k=2) ivy.array([[4, 3], [2, 1]]) >>> m = ivy.array([[[0, 1], [2, 3]], [[4, 5], [6, 7]]]) >>> m.rot90(k=2, axes=(1,2)) ivy.array([[[3, 2], [1, 0]],
- [[7, 6],
[5, 4]]])
- take_along_axis(indices, axis, /, *, mode='fill', out=None)[source]#
ivy.Array instance method variant of ivy.take_along_axis. This method simply wraps the function, and so the docstring for ivy.take_along_axis also applies to this method with minimal changes.
- Parameters:
self (
Array
) – The source array.indices (
Array
) – The indices of the values to extract.axis (
int
) – The axis over which to select values.mode (
str
) – One of: ‘clip’, ‘fill’, ‘drop’. Parameter controlling how out-of-bounds (default:'fill'
) indices will be handled.out (
Optional
[Array
]) – Optional output, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – The returned array has the same shape as indices.
Examples
>>> arr = ivy.array([[4, 3, 5], [1, 2, 1]]) >>> indices = ivy.array([[0, 1, 1], [2, 0, 0]]) >>> y = arr.take_along_axis(indices, 1) >>> print(y) ivy.array([[4, 3, 3], [1, 1, 1]])
- top_k(k, /, *, axis=-1, largest=True, sorted=True, out=None)[source]#
ivy.Array instance method variant of ivy.top_k. This method simply wraps the function, and so the docstring for ivy.top_k also applies to this method with minimal changes.
- Parameters:
self (
Array
) – The array to compute top_k for.k (
int
) – Number of top elements to retun must not exceed the array size.axis (
int
) – The axis along which we must return the top elements default value is 1. (default:-1
)largest (
bool
) – If largest is set to False we return k smallest elements of the array. (default:True
)sorted (
bool
) – If sorted is set to True we return the elements in sorted order. (default:True
)out (
Optional
[tuple
]) – Optional output tuple, for writing the result to. Must have two arrays, (default:None
) with a shape that the returned tuple broadcast to.
- Return type:
Tuple
[Array
,NativeArray
]- Returns:
ret – A named tuple with values and indices of top k elements.
Examples
With
ivy.Array
input:>>> x = ivy.array([2., 1., -3., 5., 9., 0., -4]) >>> y = x.top_k(2) >>> print(y) top_k(values=ivy.array([9., 5.]), indices=ivy.array([4, 3]))
- unique_consecutive(*, axis=None)[source]#
ivy.Array instance method variant of ivy.unique_consecutive.
This method simply wraps the function, and so the docstring for ivy.unique_consecutive also applies to this method with minimal changes.
- Return type:
Tuple
[Array
,Array
,Array
]
- vsplit(indices_or_sections, /, *, copy=None)[source]#
ivy.Array instance method variant of ivy.vsplit. This method simply wraps the function, and so the docstring for ivy.vsplit also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array.indices_or_sections (
Union
[int
,Sequence
[int
],Array
]) – If indices_or_sections is an integer n, the array is split into n equal sections, provided that n must be a divisor of the split axis. If indices_or_sections is a sequence of ints or 1-D array, then input is split at each of the indices.
- Return type:
List
[Array
]- Returns:
ret – input array split vertically.
Examples
>>> ary = ivy.array( [[[0., 1.], [2., 3.]], [[4., 5.], [6., 7.]]] ) >>> ary.vsplit(2) [ivy.array([[[0., 1.], [2., 3.]]]), ivy.array([[[4., 5.], [6., 7.]]])])
- vstack(arrays, /, *, out=None)[source]#
ivy.Array instance method variant of ivy.vstack. This method simply wraps the function, and so the docstring for ivy.vstack also applies to this method with minimal changes.
Examples
>>> x = ivy.array([[1, 2]]) >>> y = [ivy.array([[5, 6]]), ivy.array([[7, 8]])] >>> print(x.vstack(y)) ivy.array([[1, 2], [5, 6], [7, 8]])
- Return type:
Array
- class ivy.data_classes.array.experimental.norms._ArrayWithNormsExperimental[source]#
- _abc_impl = <_abc_data object>#
- batch_norm(mean, variance, /, *, offset=None, scale=None, training=False, eps=1e-05, momentum=0.1, data_format='NSC', out=None)[source]#
ivy.Array instance method variant of ivy.batch_norm. This method simply wraps the function, and so the docstring for ivy.batch_norm also applies to this method with minimal changes.
- Parameters:
self (
Union
[NativeArray
,Array
]) –Input array of default shape (N, *S, C), where N is the batch dimension, *S corresponds to any number of spatial dimensions and
C corresponds to the channel dimension.
training (
bool
) – If true, calculate and use the mean and variance of x. Otherwise, use the (default:False
) provided mean and variance.mean (
Union
[NativeArray
,Array
]) – Mean array used for input’s normalization. It can be of any shape braodcastable to (N,*S,C).variance (
Union
[NativeArray
,Array
]) – Variance array used for input’s normalization. It can be of any shape braodcastable to (N,*S,C).offset (
Optional
[Union
[Array
,NativeArray
]]) – An offset array. If present, will be added to the normalized input. (default:None
) It can be of any shape broadcastable to (N,*S,C).scale (
Optional
[Union
[Array
,NativeArray
]]) – A scale array. If present, the scale is applied to the normalized input. (default:None
) It can be of any shape broadcastable to (N,*S,C).eps (
float
) – A small float number to avoid dividing by 0. (default:1e-05
)momentum (
float
) –(default:
0.1
) the value used for the running_mean and running_var computation.Default value is 0.1.
data_format (
str
) – The ordering of the dimensions in the input, one of “NSC” or “NCS”, (default:'NSC'
) where N is the batch dimension, S represents any number of spatial dimensions and C is the channel dimension. Default is “NSC”.out (
Optional
[Tuple
[Array
,Array
,Array
]]) – optional output arrays, for writing the result to. (default:None
)
- Return type:
Tuple
[Array
,Array
,Array
]- Returns:
ret – Tuple of arrays containing the normalized input, running mean, and running variance.
- instance_norm(mean, variance, /, *, offset=None, scale=None, training=False, eps=1e-05, momentum=0.1, data_format='NSC', out=None)[source]#
ivy.Array instance method variant of ivy.instance_norm. This method simply wraps the function, and so the docstring for ivy.instance_norm also applies to this method with minimal changes.
- Parameters:
self (
Union
[NativeArray
,Array
]) –Input array of shape default (N, *S, C), where N is the batch dimension, *S corresponds to any number of spatial dimensions and
C corresponds to the channel dimension.
mean (
Union
[NativeArray
,Array
]) – Mean array of size C used for input’s normalization.variance (
Union
[NativeArray
,Array
]) – Variance array of size C used for input’s normalization.offset (
Optional
[Union
[Array
,NativeArray
]]) – An offset array of size C. If present, will be added (default:None
) to the normalized input.scale (
Optional
[Union
[Array
,NativeArray
]]) – A scale array of size C. If present, the scale is (default:None
) applied to the normalized input.training (
bool
) – If true, calculate and use the mean and variance of x. Otherwise, use the (default:False
) provided mean and variance.eps (
float
) – A small float number to avoid dividing by 0. (default:1e-05
)momentum (
float
) –(default:
0.1
) the value used for the running_mean and running_var computation.Default value is 0.1.
data_format (
str
) – The ordering of the dimensions in the input, one of “NSC” or “NCS”, (default:'NSC'
) where N is the batch dimension, S represents any number of spatial dimensions and C is the channel dimension. Default is “NSC”.out (
Optional
[Tuple
[Array
,Array
,Array
]]) – optional output array, for writing the result to. (default:None
)
- Return type:
Tuple
[Array
,Array
,Array
]- Returns:
ret –
- Tuple of array containing
the normalized input, running mean, and running variance.
- l1_normalize(axis=None, out=None)[source]#
Normalize the array to have unit L1 norm.
- Parameters:
self (
Array
) – Input array.axis (
Optional
[Union
[int
,Tuple
[int
,...
]]]) – Axis or axes along which to normalize. IfNone
, the whole array is normalized. (default:None
)out (
Optional
[Array
]) – Optional output array, for writing the result to. It must have a shape that the (default:None
) inputs broadcast to.
- Return type:
Array
- Returns:
ret – The normalized array.
Examples
>>> x = ivy.array([[1., 2.], [3., 4.]]) >>> x.l1_normalize(axis=1) ivy.array([[0.3333, 0.6667], [0.4286, 0.5714]])
- l2_normalize(axis=None, out=None)[source]#
Normalize the array to have unit L2 norm.
- Parameters:
self (
Array
) – Input array.axis (
Optional
[int
]) – Axis along which to normalize. IfNone
, the whole array (default:None
) is normalized.out (
Optional
[Array
]) – optional output array, for writing the result to. It must have a (default:None
) shape that the inputs broadcast to.
- Return type:
Array
- Returns:
ret – The normalized array.
Examples
>>> x = ivy.array([[1., 2.], [3., 4.]]) >>> x.l2_normalize(axis=1) ivy.array([[0.4472, 0.8944], [0.6, 0.8]])
- lp_normalize(*, p=2, axis=None, out=None)[source]#
Normalize the array to have Lp norm.
- Parameters:
self (
Array
) – Input array.p (
float
) – p-norm to use for normalization. (default:2
)axis (
Optional
[int
]) – Axis along which to normalize. IfNone
, the whole array (default:None
) is normalized.out (
Optional
[Array
]) – optional output array, for writing the result to. It must have a (default:None
) shape that the inputs broadcast to.
- Return type:
Array
- Returns:
ret – The normalized array.
Examples
>>> x = ivy.array([[1., 2.], [3., 4.]]) >>> x.lp_normalize(p=2, axis=1) ivy.array([[0.4472, 0.8944], [0.6, 0.8]])
- class ivy.data_classes.array.experimental.random._ArrayWithRandomExperimental[source]#
- _abc_impl = <_abc_data object>#
- bernoulli(*, logits=None, shape=None, device=None, dtype=None, seed=None, out=None)[source]#
- Parameters:
self (
Array
) – An N-D Array representing the probability of a 1 event. Each entry in the Array parameterizes an independent Bernoulli distribution. Only one of logits or probs should be passed inlogits (
Optional
[Union
[float
,Array
,NativeArray
]]) – An N-D Array representing the log-odds of a 1 event. (default:None
) Each entry in the Array parameterizes an independent Bernoulli distribution where the probability of an event is sigmoid (logits). Only one of logits or probs should be passed in.shape (
Optional
[Union
[Shape
,NativeShape
]]) – If the given shape is, e.g ‘(m, n, k)’, then ‘m * n * k’ samples are drawn. (default:None
) (Default value = ‘None’, where ‘ivy.shape(logits)’ samples are drawn)device (
Optional
[Union
[Device
,NativeDevice
]]) – device on which to create the array ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. (default:None
) (Default value = None).dtype (
Optional
[Union
[Dtype
,NativeDtype
]]) – output array data type. Ifdtype
isNone
, the output array data (default:None
) type will be the default floating-point data type. DefaultNone
seed (
Optional
[int
]) – A python integer. Used to create a random seed distribution (default:None
)out (
Optional
[Array
]) – optional output array, for writing the result to. It must (default:None
) have a shape that the inputs broadcast to.
- Returns:
ret – Drawn samples from the Bernoulli distribution
- beta(alpha, beta, /, *, device=None, dtype=None, seed=None, out=None)[source]#
ivy.Array instance method variant of ivy.beta. This method simply wraps the function, and so the docstring for ivy.beta also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input Array.alpha (
Union
[int
,Array
,NativeArray
]) – The first parameter of the beta distribution.beta (
Union
[int
,Array
,NativeArray
]) – The second parameter of the beta distribution.device (
Optional
[Union
[Device
,NativeDevice
]]) – device on which to create the array. (default:None
)dtype (
Optional
[Union
[Dtype
,NativeDtype
]]) – output array data type. Ifdtype
isNone
, the output array data (default:None
) type will be the default data type. DefaultNone
seed (
Optional
[int
]) – A python integer. Used to create a random seed distribution (default:None
)out (
Optional
[Array
]) – optional output array, for writing the result to. It must have a shape (default:None
) that the inputs broadcast to.
- Return type:
Array
- Returns:
ret – Drawn samples from the parameterized beta distribution with the shape of the array.
- dirichlet(*, size=None, dtype=None, seed=None, out=None)[source]#
ivy.Array instance method variant of ivy.dirichlet. This method simply wraps the function, and so the docstring for ivy.shuffle also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Sequence of floats of length ksize (
Optional
[Union
[Shape
,NativeShape
]]) – optional int or tuple of ints, Output shape. If the given shape is, (default:None
) e.g., (m, n), then m * n * k samples are drawn. Default is None, in which case a vector of length k is returned.dtype (
Optional
[Union
[Dtype
,NativeDtype
]]) – output array data type. Ifdtype
isNone
, the output array data (default:None
) type will be the default floating-point data type. DefaultNone
seed (
Optional
[int
]) – A python integer. Used to create a random seed distribution (default:None
)out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – The drawn samples, of shape (size, k).
Examples
>>> alpha = ivy.array([1.0, 2.0, 3.0]) >>> alpha.dirichlet() ivy.array([0.10598304, 0.21537054, 0.67864642])
>>> alpha = ivy.array([1.0, 2.0, 3.0]) >>> alpha.dirichlet(size = (2,3)) ivy.array([[[0.48006698, 0.07472073, 0.44521229], [0.55479872, 0.05426367, 0.39093761], [0.19531053, 0.51675832, 0.28793114]],
- [[0.12315625, 0.29823365, 0.5786101 ],
[0.15564976, 0.50542368, 0.33892656], [0.1325352 , 0.44439589, 0.42306891]]])
- gamma(alpha, beta, /, *, device=None, dtype=None, seed=None, out=None)[source]#
ivy.Array instance method variant of ivy.gamma. This method simply wraps the function, and so the docstring for ivy.gamma also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input Array.alpha (
Union
[int
,Array
,NativeArray
]) – The first parameter of the gamma distribution.beta (
Union
[int
,Array
,NativeArray
]) – The second parameter of the gamma distribution.device (
Optional
[Union
[Device
,NativeDevice
]]) – device on which to create the array. (default:None
)dtype (
Optional
[Union
[Dtype
,NativeDtype
]]) – output array data type. Ifdtype
isNone
, the output array data (default:None
) type will be the default data type. DefaultNone
seed (
Optional
[int
]) – A python integer. Used to create a random seed distribution (default:None
)out (
Optional
[Array
]) – optional output array, for writing the result to. It must have a shape (default:None
) that the inputs broadcast to.
- Return type:
Array
- Returns:
ret – Drawn samples from the parameterized gamma distribution with the shape of the input array.
- poisson(*, shape=None, device=None, dtype=None, seed=None, out=None)[source]#
- Parameters:
self (
Array
) – Input Array of rate paramter(s). It must have a shape that is broadcastable to the requested shapeshape (
Optional
[Union
[Shape
,NativeShape
]]) – If the given shape is, e.g ‘(m, n, k)’, then ‘m * n * k’ samples are drawn. (default:None
) (Default value = ‘None’, where ‘ivy.shape(lam)’ samples are drawn)device (
Optional
[Union
[Device
,NativeDevice
]]) – device on which to create the array ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. (default:None
) (Default value = None).dtype (
Optional
[Union
[Dtype
,NativeDtype
]]) – output array data type. Ifdtype
isNone
, the output array data (default:None
) type will be the default floating-point data type. DefaultNone
seed (
Optional
[int
]) – A python integer. Used to create a random seed distribution (default:None
)out (
Optional
[Array
]) – optional output array, for writing the result to. It must have a shape that (default:None
) the inputs broadcast to.
- Returns:
ret – Drawn samples from the parameterized poisson distribution.
Examples
>>> lam = ivy.array([1.0, 2.0, 3.0]) >>> lam.poisson() ivy.array([1., 4., 4.])
>>> lam = ivy.array([1.0, 2.0, 3.0]) >>> lam.poisson(shape=(2,3)) ivy.array([[0., 2., 2.], [1., 2., 3.]])
- class ivy.data_classes.array.experimental.searching._ArrayWithSearchingExperimental[source]#
- _abc_impl = <_abc_data object>#
- unravel_index(shape, /, *, out=None)[source]#
ivy.Array instance method variant of ivy.unravel_index. This method simply wraps the function, and so the docstring for ivy.unravel_index also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array.shape (
Tuple
[int
]) – The shape of the array to use for unraveling indices.out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Tuple
[Array
]- Returns:
ret – Tuple with arrays that have the same shape as the indices array.
Examples
>>> indices = ivy.array([22, 41, 37]) >>> indices.unravel_index((7,6)) (ivy.array([3, 6, 6]), ivy.array([4, 5, 1]))
- class ivy.data_classes.array.experimental.set._ArrayWithSetExperimental[source]#
- _abc_impl = <_abc_data object>#
- class ivy.data_classes.array.experimental.sorting._ArrayWithSortingExperimental[source]#
- _abc_impl = <_abc_data object>#
- lexsort(*, axis=-1, out=None)[source]#
ivy.Array instance method variant of ivy.lexsort. This method simply wraps the function, and so the docstring for ivy.lexsort also applies to this method with minimal changes.
- Parameters:
self (
Array
) – input array.axis (
int
) – axis of each key to be indirectly sorted. (default:-1
) By default, sort over the last axis of each key.out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – array of integer indices with shape N, that sort the input array as keys.
Examples
>>> a = [1,5,1,4,3,4,4] # First column >>> b = [9,4,0,4,0,2,1] # Second column >>> keys = ivy.asarray([b,a]) >>> keys.lexsort() # Sort by a, then by b array([2, 0, 4, 6, 5, 3, 1])
- class ivy.data_classes.array.experimental.statistical._ArrayWithStatisticalExperimental[source]#
- _abc_impl = <_abc_data object>#
- bincount(*, weights=None, minlength=0, out=None)[source]#
ivy.Array instance method variant of ivy.bincount. This method simply wraps the function, and so the docstring for ivy.bincount also applies to this method with minimal changes.
- Parameters:
self – Input array. The array is flattened if it is not already 1-dimensional.
weights (
Optional
[Array
]) – Optional weights, array of the same shape as self. (default:None
)minlength (
int
) – A minimum number of bins for the output array. (default:0
)out (
Optional
[Array
]) – An array of the same shape as the returned array, or of the shape (default:None
) (minlength,) if minlength is specified.
- Return type:
Array
- Returns:
ret – The result of binning the input array.
Examples
>>> a = ivy.array([0, 1, 1, 3, 2, 1, 7]) >>> a.bincount() ivy.array([1, 3, 1, 1, 0, 0, 0, 1]) >>> a.bincount(minlength=10) ivy.array([1, 3, 1, 1, 0, 0, 0, 1, 0, 0]) >>> a.bincount(weights=ivy.array([0.3, 0.5, 0.2, 0.7, 1., 0.6, 1.])) ivy.array([0.3, 1.3, 1. , 0.7, 0. , 0. , 0. , 1. ])
- corrcoef(*, y=None, rowvar=True, out=None)[source]#
ivy.Array instance method variant of ivy.corrcoef. This method simply wraps the function, and so the docstring for ivy.corrcoef also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array.y (
Optional
[Array
]) – An additional input array. (default:None
) y has the same shape as x.rowvar (
bool
) – If rowvar is True (default), then each row represents a variable, with (default:True
) observations in the columns. Otherwise, the relationship is transposed: each column represents a variable, while the rows contain observations.
- Return type:
Array
- Returns:
ret – The corrcoef of the array elements.
Examples
>>> a = ivy.array([[0., 1., 2.], [2., 1., 0.]]) >>> a.corrcoef() ivy.array([[ 1., -1.], [-1., 1.]]) >>> a.corrcoef(rowvar=False) ivy.array([[ 1., nan, -1.], [nan, nan, nan], [-1., nan, 1.]])
- histogram(*, bins=None, axis=None, extend_lower_interval=False, extend_upper_interval=False, dtype=None, range=None, weights=None, density=False, out=None)[source]#
ivy.Array instance method variant of ivy.histogram. This method simply wraps the function, and so the docstring for ivy.histogram also applies to this method with minimal changes.
- Parameters:
self (
Array
) – input array.bins (
Optional
[Union
[int
,Array
,NativeArray
,str
]]) – ifbins
is an int, it defines the number of equal-width bins in the (default:None
) given range. ifbins
is an array, it defines a monotonically increasing array of bin edges, including the rightmost edge, allowing for non-uniform bin widths.axis (
Optional
[Union
[Array
,NativeArray
]]) – dimension along which maximum values must be computed. By default, the (default:None
) maximum value must be computed over the entire array. Default:None
.extend_lower_interval (
Optional
[bool
]) – if True, extend the lowest interval I0 to (-inf, c1]. (default:False
)extend_upper_interval (
Optional
[bool
]) – ff True, extend the upper interval I_{K-1} to [c_{K-1}, +inf). (default:False
)dtype (
Optional
[Union
[Dtype
,NativeDtype
]]) – the output type. (default:None
)range (
Optional
[Tuple
[float
]]) – the lower and upper range of the bins. The first element of the range must (default:None
) be less than or equal to the second.weights (
Optional
[Union
[Array
,NativeArray
]]) – each value ina
only contributes its associated weight towards the bin (default:None
) count (instead of 1). Must be of the same shape as a.density (
Optional
[bool
]) – if True, the result is the value of the probability density function at the (default:False
) bin, normalized such that the integral over the range of bins is 1.out (
Optional
[Array
]) – optional output array, for writing the result to. It must have a shape that (default:None
) the inputs broadcast to.
- Return type:
Array
- Returns:
ret – a tuple containing the values of the histogram and the bin edges.
Both the description and the type hints above assumes an array input for
simplicity, but this function is *nestable, and therefore also accepts*
ivy.Container
instances in place of any of the arguments.
Examples
With
ivy.Array
input:>>> x = ivy.array([0, 1, 2]) >>> y = ivy.array([0., 0.5, 1., 1.5, 2.]) >>> z = ivy.histogram(x, bins=y) >>> print(z) (ivy.array([1, 0, 1, 1]), ivy.array([0. , 0.5, 1. , 1.5, 2. ]))
- igamma(*, x, out=None)[source]#
ivy.Array instance method variant of ivy.igamma. This method simply wraps the function, and so the docstring for ivy.igamma also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array.x (
Union
[Array
,NativeArray
]) – An additional input array. x has the same type as a.out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – The lower incomplete gamma function of the array elements.
Examples
>>> a = ivy.array([2.5]) >>> x = ivy.array([1.7, 1.2]) >>> a.igamma(x) ivy.array([0.3614, 0.2085])
- median(*, axis=None, keepdims=False, out=None)[source]#
ivy.Array instance method variant of ivy.median. This method simply wraps the function, and so the docstring for ivy.median also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array.axis (
Optional
[Union
[int
,Tuple
[int
]]]) – Axis or axes along which the medians are computed. The default is to compute (default:None
) the median along a flattened version of the array.keepdims (
bool
) – If this is set to True, the axes which are reduced are left in the result (default:False
) as dimensions with size one.out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – The median of the array elements.
Examples
>>> a = ivy.array([[10, 7, 4], [3, 2, 1]]) >>> a.median() 3.5 >>> a.median(axis=0) ivy.array([6.5, 4.5, 2.5])
- nanmean(*, axis=None, keepdims=False, dtype=None, out=None)[source]#
ivy.Array instance method variant of ivy.nanmean. This method simply wraps the function, and so the docstring for ivy.nanmean also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array.axis (
Optional
[Union
[int
,Tuple
[int
]]]) – Axis or axes along which the means are computed. (default:None
) The default is to compute the mean of the flattened array.keepdims (
bool
) – If this is set to True, the axes which are reduced are left in the result (default:False
) as dimensions with size one. With this option, the result will broadcast correctly against the original a. If the value is anything but the default, then keepdims will be passed through to the mean or sum methods of sub-classes of ndarray. If the sub-classes methods does not implement keepdims any exceptions will be raised.dtype (
Optional
[Union
[Dtype
,NativeDtype
]]) – The desired data type of returned tensor. Default is None. (default:None
)out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – The nanmean of the array elements.
Examples
>>> a = ivy.array([[1, ivy.nan], [3, 4]]) >>> a.nanmean() 2.6666666666666665 >>> a.nanmean(axis=0) ivy.array([2., 4.])
- nanmedian(*, axis=None, keepdims=False, overwrite_input=False, out=None)[source]#
ivy.Array instance method variant of ivy.nanmedian. This method simply wraps the function, and so the docstring for ivy.nanmedian also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array.axis (
Optional
[Union
[int
,Tuple
[int
]]]) – The axis or axes along which the means are computed. (default:None
) The default is to compute the mean of the flattened array.keepdims (
bool
) – If this is set to True, the axes which are reduced are left in the result (default:False
) as dimensions with size one. With this option, the result will broadcast correctly against the original input array. If the value is anything but the default, then keepdims will be passed through to the mean or sum methods of sub-classes of ndarray. If the sub-classes methods does not implement keepdims any exceptions will be raised.overwrite_input (
bool
) – If True, then allow use of memory of input array a for calculations. (default:False
) The input array will be modified by the call to median. This will save memory when you do not need to preserve the contents of the input array. Treat the input as undefined, but it will probably be fully or partially sorted. Default is False. If overwrite_input is True and input array is not already an ndarray, an error will be raised.out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – A new array holding the result. If the input contains integers
Examples
With
ivy.array
input and default backend set as numpy:>>> a = ivy.array([[10.0, ivy.nan, 4], [3, 2, 1]]) >>> a.nanmedian() ivy.array(3.) >>> a.nanmedian(axis=0) ivy.array([6.5, 2. , 2.5])
- quantile(q, /, *, axis=None, keepdims=False, interpolation='linear', out=None)[source]#
ivy.Array instance method variant of ivy.quantile. This method simply wraps the function, and so the docstring for ivy.quantile also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array.q (
Union
[Array
,float
]) – Quantile or sequence of quantiles to compute, which must be between 0 and 1 inclusive.axis (
Optional
[Union
[int
,Sequence
[int
]]]) – Axis or axes along which the quantiles are computed. The default (default:None
) is to compute the quantile(s) along a flattened version of the array.keepdims (
bool
) – If this is set to True, the axes which are reduced are left in the result (default:False
) as dimensions with size one. With this option, the result will broadcast correctly against the original array a.interpolation (
str
) – {‘nearest’, ‘linear’, ‘lower’, ‘higher’, ‘midpoint’}. Default value: (default:'linear'
) ‘linear’. This specifies the interpolation method to use when the desired quantile lies between two data points i < j: - linear: i + (j - i) * fraction, where fraction is the fractional part of the index surrounded by i and j. - lower: i. - higher: j. - nearest: i or j, whichever is nearest. - midpoint: (i + j) / 2. linear and midpoint interpolation do not work with integer dtypes.out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – A (rank(q) + N - len(axis)) dimensional array of same dtype as a, or, if axis is None, a rank(q) array. The first rank(q) dimensions index quantiles for different values of q.
Examples
>>> a = ivy.array([[10., 7., 4.], [3., 2., 1.]]) >>> q = ivy.array(0.5) >>> a.quantile(q) ivy.array(3.5)
>>> a = ivy.array([[10., 7., 4.], [3., 2., 1.]]) >>> q = 0.5 >>> a.quantile(q) ivy.array(3.5)
>>> a.quantile(q, axis=0) ivy.array([6.5, 4.5, 2.5])
>>> a.quantile(q, axis=1) ivy.array([7., 2.])
>>> a.quantile(q, axis=1, keepdims=True) ivy.array([[7.],[2.]])
>>> a = ivy.array([1., 2., 3., 4.]) >>> q = ivy.array([0.3, 0.7]) >>> a.quantile(q, interpolation='lower') ivy.array([1., 3.])