在张量中间执行 tf.signal.fft2d [英] Perform tf.signal.fft2d in the middle of the tensor
本文介绍了在张量中间执行 tf.signal.fft2d的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 tf.Tensor
,例如形状 (31, 6, 6, 3)
.
I have a tf.Tensor
of, for example, shape (31, 6, 6, 3)
.
我想在形状 6, 6
所以,换句话说,在中间.但是,描述说:
I want to perform tf.signal.fft2d on the shapes 6, 6
so, in other words, in the middle. However, the description says:
计算输入的最内部二维二维离散傅立叶变换
Computes the 2-dimensional discrete Fourier transform over the inner-most 2 dimensions of input
我可以用 for 循环来完成,但我担心它可能非常无效.有没有最快的方法?
I could do it with a for loop but I fear it might be very ineffective. Is there a fastest way?
结果当然必须具有相同的输出形状.
The result must have the same output shape of course.
推荐答案
感谢 this 我使用 tf.transpose 实现了这个解决方案:
Thanks to this I implemented this solution using tf.transpose:
in_pad = tf.transpose(in_pad, perm=[0, 3, 1, 2])
out = tf.signal.fft2d(tf.cast(in_pad, tf.complex64))
out = tf.transpose(out, perm=[0, 2, 3, 1])
这篇关于在张量中间执行 tf.signal.fft2d的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文