hanjq17 / GMN

[ICLR 2022] The implementation for the paper "Equivariant Graph Mechanics Networks with Constraints".
https://arxiv.org/pdf/2203.06442.pdf
MIT License
56 stars 6 forks source link

构建N_body数据集时system.py文件的报错 #1

Closed coastes closed 2 years ago

coastes commented 2 years ago

尊敬的作者,您好!

最近我在复现您有关GMN论文的相关代码,在克隆代码进行运行后,构建初始n_body数据集时:

GMN-main/spatial_graph/n_body_system/dataset/system.py文件的第89行出现代码错误: l2_dist_power3 = np.power( self._l2(X, X), 3. / 2.)

错误信息为: py:89: RuntimeWarning: invalid value encountered in power

初步排查时power函数并不支持基数为负数,不知道这个问题是我这边的操作不当问题还是原有的代码问题?不知您是否有空解答我的问题,万分感谢!

hanjq17 commented 2 years ago

Hi coastes!

First of all, please note that the "error information": py:89: RuntimeWarning: invalid value encountered in power is only a RuntimeWarning instead of RuntimeError and does not interrupt the running of the dataset generation script. That is to say, you can continue to run the script and obtain the generated dataset.

The reason why there is such a warning is that line 89 in system.py is basically computing the interaction strength of the Coulomb force, which is proportional to $\frac{\vec{r}}{r^3}$,
where $r$ is the relative position between two nodes. Therefore, when computing the matrix $\frac{1}{r^3}$,
the diagonal (accounting for the distance between the same node) will be $\frac{1}{0}$, which automatically triggers the warning. However, this does not affect the correctness since afterward the diagonal will be refilled by zeros (see line 95 of dataset.py), and used in the following computation.


Summary: This is only an expected warning which does not terminate the program, and there's no bug in the code here. You can still safely run the script for data generation.

Please let me know if there's still any issue (e.g., in case your program unexpectedly terminates due to this warning) or if you succeed in the data generation.

Thanks!

coastes commented 2 years ago

Thanks for your answer, it solved my question successfully!

hanjq17 commented 2 years ago

Glad to hear that! I am closing the issue for now since it has been resolved.