我想在张量流中使用 fft2d 变换,然后用卷积层分析幅度和相位结果......我已经制作了一个带有 Lambda 层的系统来使用张量流函数并获得幅度和相位。但是当我添加 Conv2d 层时,我得到了错误
Depth of input (3) is not a multiple of input depth of filter (199) for '1_Magn_Conv_f500_k2_2/convolution' (op: 'Conv2D') with input shapes: [?,199,199,3], [2,2,199,500]
我不明白是什么shape [2,2,199,500]以及导致此错误的原因。
我试图减少网络中的层数,以检测是哪一层造成了问题。我检查了 magn_angle 输出两个张量shapes [None,199,199,3]。我正在与谷歌 colab 合作。
这是重现错误的最少代码
inpt = Input(shape = (199, 199, 3),name=str(0)+'_'+'Image')
def magn_angle(x):
x = Lambda(lambda x:K.cast(x,dtype=tf.complex64))(x)
x_list_magn = []
x_list_angle = []
for i in range(3):
fft = Lambda(lambda x: tf.fft2d(x[:,:,:,i]), output_shape=(None,199,199))(x)# 2-dimensional discrete Fourier transform over the inner-most 2 dimensions
x_list_magn.append(Lambda(lambda fft:K.expand_dims(tf.math.abs(fft),axis=-1), output_shape=(None,199,199))(fft))
x_list_angle.append(Lambda(lambda fft: K.expand_dims(tf.math.angle(fft),axis=-1), output_shape=(None,199,199))(fft))
magn = Concatenate()(x_list_magn)
angle = Concatenate()(x_list_angle)
magn = Lambda(lambda magn: K.cast(magn,dtype=tf.float32), output_shape=(None,199,199))(magn)
angle = Lambda(lambda angle: K.cast(angle,dtype=tf.float32), output_shape=(None,199,199))(angle)
return magn,angle
magn, angle = magn_angle(inpt)
magn = Conv2D(filters=500,kernel_size=(2,2),activation=None,strides=(1,1),padding='SAME',name=str(1)+'_'+'Magn_Conv_f500_k2',data_format="channels_last")(magn)
...
哪个输出
InvalidArgumentError: Depth of input (3) is not a multiple of input depth of filter (199) for '1_Magn_Conv_f500_k2_3/convolution' (op: 'Conv2D') with input shapes: [?,199,199,3], [2,2,199,500].
动漫人物
相关分类