Skip to content

Commit

Permalink
Merge pull request #71 from choderalab/fix-pki-readout-math
Browse files Browse the repository at this point in the history
Adjust PKiReadout math for numerical stability
  • Loading branch information
kaminow authored Sep 18, 2024
2 parents 0e06eda + b56a9f4 commit 4cb38e6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mtenn/readout.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ class PKiReadout(Readout):
\mathrm{pK_i} &= \mathrm{-log10(K_i)}
\mathrm{pK_i} &= \mathrm{-log10(exp(\Delta G))}
\mathrm{pK_i} &= \\frac{\mathrm{-ln(exp(\Delta G))}}{\mathrm{ln(10)}}
\mathrm{pK_i} &= \\frac{\mathrm{-\Delta G}}{\mathrm{ln(10)}}
"""

def __repr__(self):
Expand All @@ -168,6 +172,6 @@ def forward(self, delta_g):
torch.Tensor
Calculated :math:`\mathrm{pK_i}` value.
"""
pki = -torch.log10(torch.exp(delta_g))
pki = -delta_g / torch.log(torch.tensor(10, dtype=delta_g.dtype))

return pki

0 comments on commit 4cb38e6

Please sign in to comment.