I have a 2-channel numpy array of shape (64, 64, 2) as input to my CNN. I want to build a customized loss function as described in https://www.tensorflow.org/guide/keras/train_and_evaluate :
def basic_loss_function(y_true, y_pred):
return tf.math.reduce_mean(tf.abs(y_true - y_pred))
model.compile(optimizer=keras.optimizers.Adam(),
loss=basic_loss_function)
model.fit(x_train, y_train, batch_size=64, epochs=3)
But I want to something more complicated that this basic one. What I need is to do an inverse DFT (ifft2d) and my y_pred and y_true are expected to be each of shape (64,64,2), with the 2 channels being the real and imaginary parts of a fft2. How can I access correctly the y_pred and y_true channels (which are some kind of keras/tensor layer I guess?) to rebuild a complex number in the form RealPart+1j*ImagPart (in numpy it would be y_pred[:,:,0] and y_pred[:,:,1] ) ?
--> In summary, does someone know exactly what kind of object is y_pred and y_true and how to access their channels/elements? (This is not easy to debug since would need to be run in a compiled CNN, so better know it beforehand)