Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K
JAX  documentation - Home

jax.numpy.power

Contents

jax.numpy.power#

jax.numpy.power(x1,x2,/)[source]#

Calculate element-wise basex1 exponential ofx2.

JAX implementation ofnumpy.power.

Parameters:
  • x1 (ArrayLike) – scalar or array. Specifies the bases.

  • x2 (ArrayLike) – scalar or array. Specifies the exponent.x1 andx2 should eitherhave same shape or be broadcast compatible.

Returns:

An array containing the basex1 exponentials ofx2 with same dtypeas input.

Return type:

Array

Note

  • Whenx2 is a concrete integer scalar,jnp.power lowers tojax.lax.integer_pow().

  • Whenx2 is a traced scalar or an array,jnp.power lowers tojax.lax.pow().

  • jnp.power raises aTypeError for integer type raised to a concretenegative integer power. For a non-concrete power, the operation is invalidand the returned value is implementation-defined.

  • jnp.power returnsnan for negative value raised to the power ofnon-integer values.

See also

  • jax.lax.pow(): Computes element-wise power,\(x^y\).

  • jax.lax.integer_pow(): Computes element-wise power\(x^y\), where\(y\) is a fixed integer.

  • jax.numpy.float_power(): Computes the first array raised to the powerof second array, element-wise, by promoting to the inexact dtype.

  • jax.numpy.pow(): Computes the first array raised to the power of secondarray, element-wise.

Examples

Inputs with scalar integers:

>>>jnp.power(4,3)Array(64, dtype=int32, weak_type=True)

Inputs with same shape:

>>>x1=jnp.array([2,4,5])>>>x2=jnp.array([3,0.5,2])>>>jnp.power(x1,x2)Array([ 8.,  2., 25.], dtype=float32)

Inputs with broadcast compatibility:

>>>x3=jnp.array([-2,3,1])>>>x4=jnp.array([[4,1,6],...[1.3,3,5]])>>>jnp.power(x3,x4)Array([[16.,  3.,  1.],       [nan, 27.,  1.]], dtype=float32)
Contents

[8]ページ先頭

©2009-2025 Movatter.jp