Open jdellag opened 11 months ago
However, when trying to use this optimizer after setting the default precision to float64
Did you call deepxde.config.real.set_float64()
right after import deepxde
? If not, do it.
Yes, trying that and any combination of the following three;
deepxde.config.set_default_float("float64")
tf.keras.backend.set_floatx("float64")
deepxde.config.real.set_float64()
has not yielded anything other than the error posted above.
Can you show all the code?
I finally nailed down what it was, and I'm surprised I didn't catch it earlier. I have a trainable variable U that I am interested in, but I noticed that when writing the value of U at every 500 iterations that it was a float32 even though I explicitly set all reals to be float64. Specifying the dtype of U when I initialized it as U = dde.variable(1.0, dtype='float64') did the trick.
Can we get this change commited in the code base?
Good point. @jdellag Would like to submit a PR to fix it?
You only need to modify here https://github.com/lululxvi/deepxde/blob/5b21146dd2c73e8df7d31acaad8b5604d30fc3e8/deepxde/backend/tensorflow_compat_v1/tensor.py#L83
I've been working on a Navier Stokes problem and would like to try to further optimize my model after training with Adam like many of the examples I have seen. However, when trying to use this optimizer after setting the default precision to float64, I am receiving the following error:
I am puzzled as to why this is happening. FWIW, I have run into this error on both the DeepXDE docker image and while trying to run on a M1 Mac as well (both with tensorflow.compat.v1 backends). What surprises me even more is that I have not seen this specific type of error on this GitHub or anywhere else on the internet for that matter. Any ideas on what this could be?