how to convert tensorflow tensor to numpy array from given example?

Question:

I am trying to compute Fast Fourier Transform (fft2d) but the following code provides the error:

print("type(pred[2]): ", type(pred[2]))
pred[2] = tf.make_ndarray(pred[2])
fft2_pre = np.fft.fft2(pred[2])

The error and output:

type(pred[2]):  <class 'tensorflow.python.framework.ops.Tensor'>
AttributeError: 'Tensor' object has no attribute 'tensor_shape'

how it could be solved?

Asked By: Sanjay Gupta

||

Answers:

temp = tf.cast(pred[2], dtype=tf.complex64)
temp = tf.signal.fft(temp)
Answered By: Mohammad Ahmed
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.