diprism / fggs

Factor Graph Grammars in Python
MIT License
13 stars 3 forks source link

More principled use of nan_to_num() #138

Closed davidweichiang closed 2 years ago

davidweichiang commented 2 years ago

Previously there were nan_to_num()s sprinkled ad hoc to make training work even when the sum-product is infinite. Now semirings.py consistently follows the rule that inf * 0 = 0 (e.g., https://link-springer-com.proxy.library.nd.edu/chapter/10.1007/978-3-642-01492-5_1 page 7) to avoid NaNs, and there is just one use of nan_to_num() outside of semirings.py.