-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate the multihit model into the DNSM framework #60
Conversation
faf5239
to
a73a6ac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, this is looking almost done!
@@ -142,6 +150,7 @@ def clone(self): | |||
self.all_rates.copy(), | |||
self.all_subs_probs.copy(), | |||
self._branch_lengths.copy(), | |||
multihit_model=copy.deepcopy(self.multihit_model), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This deepcopy and the one below are no longer necessary now that you are copying in the init, right?
@@ -14,6 +15,15 @@ | |||
from netam.dnsm import DNSMBurrito, train_val_datasets_of_pcp_df | |||
|
|||
|
|||
def force_spawn(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were going to move this into common, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and remove the other instance)
Here we add the multihit model to the DNSM. We chose to do so by storing the multihit model, as an object, as part of the DNSMDataset object, and bringing it into
molevol.py
.This is a bit of a break from the previous work, which was able to stay in tensor land rather than object land. E.g.
molevol.py
now has objects frommodels.py
.Here is the rationale.
Previously, we could pre-compute the per-site rates and then all future calculations would be relative to those rates. To emphasize, the per-site rates don't depend on the branch lengths or anything.
Here, we have the multihit multipliers being applied after the codon level calculations. These codon calculations depend on the branch lengths and rates in a nonlinear way. Thus we can't precompute rates and then apply them in a straightforward way.
In theory we could stay more in tensor land by precomputing a 64*64 (this is codon by codon, because the hit classes depend on the source and dest codon) offset per site per sequence, and multiplying that after the codon aggregation step. However, that seems wasteful of memory and overkill.
So we have decided to apply the multihit correction using the forward function of the corresponding object, which is exactly what it's meant to do.
In any case, all of this work happens only in the branch length optimization phase of making the DNSMs, and not the transformer backprop.