tf.compat.v1.math.exp
Stay organized with collections
Save and categorize content based on your preferences.
Computes exponential of x element-wise. \(y = e^x\).
tf.compat.v1.math.exp(
x, name=None
)
This function computes the exponential of the input tensor element-wise.
i.e. math.exp(x)
or \(e^x\), where x
is the input tensor.
\(e\) denotes Euler's number and is approximately equal to 2.718281.
Output is positive for any real input.
x = tf.constant(2.0)
tf.math.exp(x)
<tf.Tensor: shape=(), dtype=float32, numpy=7.389056>
x = tf.constant([2.0, 8.0])
tf.math.exp(x)
<tf.Tensor: shape=(2,), dtype=float32,
numpy=array([ 7.389056, 2980.958 ], dtype=float32)>
For complex numbers, the exponential value is calculated as
\[
e^{x+iy} = {e^x} {e^{iy} } = {e^x} ({\cos (y) + i \sin (y)})
\]
For 1+1j
the value would be computed as:
\[
e^1 (\cos (1) + i \sin (1)) = 2.7182817 \times (0.5403023+0.84147096j)
\]
x = tf.constant(1 + 1j)
tf.math.exp(x)
<tf.Tensor: shape=(), dtype=complex128,
numpy=(1.4686939399158851+2.2873552871788423j)>
Args |
x
|
A tf.Tensor . Must be one of the following types: bfloat16 , half ,
float32 , float64 , complex64 , complex128 .
|
name
|
A name for the operation (optional).
|
Equivalent to np.exp
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-26 UTC."],[],[],null,["# tf.compat.v1.math.exp\n\n|------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/math_ops.py#L5459-L5506) |\n\nComputes exponential of x element-wise. \\\\(y = e\\^x\\\\). \n\n tf.compat.v1.math.exp(\n x, name=None\n )\n\nThis function computes the exponential of the input tensor element-wise.\ni.e. [`math.exp(x)`](https://www.tensorflow.org/api_docs/python/tf/math/exp) or \\\\(e\\^x\\\\), where `x` is the input tensor.\n\\\\(e\\\\) denotes Euler's number and is approximately equal to 2.718281.\nOutput is positive for any real input. \n\n x = tf.constant(2.0)\n tf.math.exp(x)\n \u003ctf.Tensor: shape=(), dtype=float32, numpy=7.389056\u003e\n\n x = tf.constant([2.0, 8.0])\n tf.math.exp(x)\n \u003ctf.Tensor: shape=(2,), dtype=float32,\n numpy=array([ 7.389056, 2980.958 ], dtype=float32)\u003e\n\nFor complex numbers, the exponential value is calculated as\n\n\\\\\\[\ne\\^{x+iy} = {e\\^x} {e\\^{iy} } = {e\\^x} ({\\\\cos (y) + i \\\\sin (y)})\n\\\\\\]\n\nFor `1+1j` the value would be computed as:\n\n\\\\\\[\ne\\^1 (\\\\cos (1) + i \\\\sin (1)) = 2.7182817 \\\\times (0.5403023+0.84147096j)\n\\\\\\] \n\n x = tf.constant(1 + 1j)\n tf.math.exp(x)\n \u003ctf.Tensor: shape=(), dtype=complex128,\n numpy=(1.4686939399158851+2.2873552871788423j)\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------|--------------------------------------------------------------------------------------------------------------------------------------------------|\n| `x` | A [`tf.Tensor`](../../../../tf/Tensor). Must be one of the following types: `bfloat16`, `half`, `float32`, `float64`, `complex64`, `complex128`. |\n| `name` | A name for the operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A [`tf.Tensor`](../../../../tf/Tensor). Has the same type as `x`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nnumpy compatibility\n-------------------\n\n\u003cbr /\u003e\n\nEquivalent to np.exp\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e"]]