I’m currently working on the dev branch and training a FlowMatching Inference network using an OnlineDataset. However, I occasionally encounter the following warnings:
/data/homes/reiser/.conda/envs/sabi_env/lib/python3.11/site-packages/bayesflow/utils/numpy_utils.py:7: RuntimeWarning: divide by zero encountered in log
return np.log(x / (1 - x))
/data/homes/reiser/.conda/envs/sabi_env/lib/python3.11/site-packages/numpy/core/_methods.py:173: RuntimeWarning: invalid value encountered in subtract
x = asanyarray(arr - arrmean)
/data/homes/reiser/.conda/envs/sabi_env/lib/python3.11/site-packages/bayesflow/adapters/transforms/standardize.py:86: RuntimeWarning: invalid value encountered in subtract
return (data - mean) / std
This sometimes occurs after 71 epochs, and other times after 300 epochs, eventually leading to NaN values in the loss.
Do you have any suggestions on how to resolve this issue?
Thanks in advance!
Hey Philipp, this seems to be coming from the Adapter. I suspect that the constrain method is to blame. Could you try removing it and see if the warnings disappear?
Looks like the inverse sigmoid transform from the adapter.constrain() is at fault here. When the sampled w is sufficiently close to 0.6 or 1.4, we get division by zero and infinite return values.
Since we don’t support making the boundaries inclusive yet, can you please add a small value to either end of the constraint and check if this helps: