Can we optimize the frequency by comparing the difference between 2D sine wave images?

I set a random target frequency f1, and another randomly initial frequency f2. Since the f1 is unknown now, I want to use the gradient-based optimization to recover the f2 by comparing the difference between the 2D sine wave image m1 generated by f1 and m2 generated by f2 in the same way. The 2D sine wave image looks like the following:

I think this is an interesting experiment, but finally, I failed to recover the correct frequency. Loss functions such as MSE, VGG, and even FFT cannot lead the frequency to the correct one.

Is it possible to recover the frequency in this way?