Skip to content

Commit

Permalink
Adjust pKiReadout math for numerical stability.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaminow committed Sep 13, 2024
1 parent 0e06eda commit b56a9f4
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 b56a9f4

Please sign in to comment.