jax.numpy.log
Contents
jax.numpy.log#
- jax.numpy.log(x,/)[source]#
Calculate element-wise natural logarithm of the input.
JAX implementation of
numpy.log.- Parameters:
x (ArrayLike) – input array or scalar.
- Returns:
An array containing the logarithm of each element in
x, promotes to inexactdtype.- Return type:
See also
jax.numpy.exp(): Calculates element-wise exponential of the input.jax.numpy.log2(): Calculates base-2 logarithm of each element of input.jax.numpy.log1p(): Calculates element-wise logarithm of one plus input.
Examples
jnp.logandjnp.expare inverse functions of each other. Applyingjnp.logon the result ofjnp.exp(x)yields the original inputx.>>>x=jnp.array([2,3,4,5])>>>jnp.log(jnp.exp(x))Array([2., 3., 4., 5.], dtype=float32)
Using
jnp.logwe can demonstrate well-known properties of logarithms, suchas\(log(a*b) = log(a)+log(b)\).>>>x1=jnp.array([2,1,3,1])>>>x2=jnp.array([1,3,2,4])>>>jnp.allclose(jnp.log(x1*x2),jnp.log(x1)+jnp.log(x2))Array(True, dtype=bool)
Contents
