Python – tensorflow.math.conj()
TensorFlow 是由 Google 设计的开源Python库,用于开发机器学习模型和深度学习神经网络。 conj()用于查找复输入张量的元素方式复共轭。
Syntax: tensorflow.math.conj( x, name)
Parameters:
- x: It’s a tensor and it must have numeric values.
- name(optional): It’s defines the name for the operation.
Returns:
It return a tensor of same dtype as x.
It will raise TypeError if input is not numeric tensor.
示例 1:
Python3
# importing the library
import tensorflow as tf
# Initializing the input tensor
a = tf.constant([1+5j,3+2j,4+1j],dtype = tf.complex128)
# Printing the input tensor
print('a: ',a)
# Finding the complex conjugate
res = tf.math.conj(a)
# Printing the result
print('Complex Conjugate: ',res)
Python3
# importing the library
import tensorflow as tf
# Initializing the input tensor
a = tf.constant([1, 2, 3],dtype = tf.float64)
# Printing the input tensor
print('a: ',a)
# Finding the complex conjugate
res = tf.math.conj(a)
# Printing the result
print('Complex Conjugate: ',res)
输出:
a: tf.Tensor([1.+5.j 3.+2.j 4.+1.j], shape=(3,), dtype=complex128)
Complex Conjugate: tf.Tensor([1.-5.j 3.-2.j 4.-1.j], shape=(3,), dtype=complex128)
示例 2:此示例使用 dtype float64 的输入。
Python3
# importing the library
import tensorflow as tf
# Initializing the input tensor
a = tf.constant([1, 2, 3],dtype = tf.float64)
# Printing the input tensor
print('a: ',a)
# Finding the complex conjugate
res = tf.math.conj(a)
# Printing the result
print('Complex Conjugate: ',res)
输出:
a: tf.Tensor([1. 2. 3.], shape=(3,), dtype=float64)
Complex Conjugate: tf.Tensor([1. 2. 3.], shape=(3,), dtype=float64)