我希望对使用ImageDataGenerator加载的输入数据集进行FFT。当我沿着通道维度将FFT复输出的实部和复部叠加在一起时,采用FFT将使通道数量加倍。ImageDataGenerator类的preprocessing_function属性应该输出一个与输入形状相同的Numpy张量,所以我不能使用它。 我尝试直接在ImageDataGenerator.flow_from_directory()输出上应用tf.math.fft2d,但它消耗了太多RAM,导致程序在Google colab上崩溃。我尝试的另一种方法是添加一个自定义层来计算FFT,作为神经网络的第一层,但这会增加训练时间。因此,我希望将其作为预处理步骤。 谁能建议一种有效的方法在ImageDataGenerator上应用函数
您可以自定义} 需要
ImageDataGenerator
,但我没有理由认为这比在第一层中使用它快。这似乎是一个代价高昂的操作,因为^{complex64
或complex128
数据类型。所以它需要转换,然后再转换回来,因为神经网络权重是tf.float32
,而其他图像处理函数不采用complex
数据类型相关问题 更多 >
编程相关推荐