jax.numpy.positive#

jax.numpy.positive(x, /)[原始碼]#

傳回輸入的逐元素正值。

numpy.positive 的 JAX 實作。

參數:

x (ArrayLike) – 輸入陣列或純量

傳回:

x 形狀和 dtype 相同的陣列,包含 +x

傳回類型:

Array

注意

jnp.positive 等於 x.copy(),且僅針對支援算術運算的類型定義。

另請參閱

範例

對於實值輸入

>>> x = jnp.array([-5, 4, 7., -9.5])
>>> jnp.positive(x)
Array([-5. ,  4. ,  7. , -9.5], dtype=float32)
>>> x.copy()
Array([-5. ,  4. ,  7. , -9.5], dtype=float32)

對於複數輸入

>>> x1 = jnp.array([1-2j, -3+4j, 5-6j])
>>> jnp.positive(x1)
Array([ 1.-2.j, -3.+4.j,  5.-6.j], dtype=complex64)
>>> x1.copy()
Array([ 1.-2.j, -3.+4.j,  5.-6.j], dtype=complex64)

對於 uint32

>>> x2 = jnp.array([6, 0, -4]).astype(jnp.uint32)
>>> x2
Array([         6,          0, 4294967292], dtype=uint32)
>>> jnp.positive(x2)
Array([         6,          0, 4294967292], dtype=uint32)