版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010255642/article/details/82110665
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 27 11:16:32 2018
@author: myhaspl
"""
# TensorFlow and tf.keras
import tensorflow as tf
sess=tf.Session()
with sess:
x = tf.constant([[-2.25 + 4.75j], [-3.25 + 5.75j]])
print x.eval()
print tf.abs(x).eval()
x=tf.constant([12.22,-32])
print x.eval()
print tf.abs(x).eval()
注意:对复数x+yi求绝对值,相当于 sqrt(x^2+y^2)