Structure confidence heads
TM Ranking Score
Free account with email, Google or GitHub. Your code runs in an isolated PyTorch sandbox.
Your task
Combine supplied confidence summaries into one ranking score per structure.
Function signature
tm_ranking_score(
ptm: torch.Tensor,
iptm: torch.Tensor,
ranking_mix: float = 0.8,
) -> torch.TensorWorked example
Mix two confidence scores
With ptm=[0.5], iptm=[0.75], and ranking_mix=0.8, return ranking_score=[0.2·0.5+0.8·0.75]=[0.7]. This focused lesson combines supplied scores; it has no interface fallback or clash penalty.
Parameters
| Parameter | Shape and meaning |
|---|---|
ptmtorch.Tensor | [B]Supplied predicted TM score. |
iptmtorch.Tensor | [B]Supplied interface TM score. |
ranking_mixfloatDefault 0.8 | Weight of the interface-TM term in mixed ranking. |
Return
torch.Tensor · [B]
Return Combined ranking score per structure.
Required behavior
- Use
(1-mix)\,pTM+mix\,ipTM, where ranking_mix defaults to 0.8 and lies in[0,1]. Scores are supplied batch vectors; this lesson does not recompute TM probabilities. - Return this mixture directly, including for single-chain inputs.
- Use CPU float32/float64 tensors with one shared floating dtype/device. Preserve strided layouts and do not mutate supplied tensors.
- Use raw tensor operations, not a ready-made implementation of the requested primitive. Supplied parameters and random variates must not be reinitialized.
Why this matters
The usual multimer TM ranking mixture emphasizes interface confidence while retaining a smaller contribution from global fold confidence. This lesson combines already-computed scores; it is not the full AF3 clash/disorder ranking rule.
Starter code
You write the body of this function in the BioTorch workspace. Your code runs in an isolated PyTorch sandbox; Run checks the public examples and Submit grades the full test suite, including gradients.
import torch
def tm_ranking_score(
ptm: torch.Tensor, # (B,)
iptm: torch.Tensor, # (B,)
ranking_mix: float = 0.8,
) -> torch.Tensor:
"""Return a tensor with shape (B,)."""
# Implement the operation. Inputs and test setup are supplied by BioTorch.
raise NotImplementedError("Implement tm_ranking_score")
Ready to implement it?
3 progressive hints, a solution walkthrough, and grading that checks values, shapes and gradients are waiting in the workspace.
Free account with email, Google or GitHub. Your code runs in an isolated PyTorch sandbox.
Related exercises
Sources and further reading
- www.nature.com
- www.nature.com
- google-deepmind/alphafold · modules.py
- google-deepmind/alphafold · confidence.py
- facebookresearch/esm · esmfold.py
- facebookresearch/esm · esmfold.py
- google-deepmind/alphafold3 · confidence_head.py
- google-deepmind/alphafold3 · confidences.py
- google-deepmind/alphafold3 · confidences.py
- google-deepmind/alphafold3 · confidences.py
- huggingface/transformers · modeling_esmfold2.py
- Biohub/esm · vqvae.py
- Biohub/esm · vqvae.py
- RosettaCommons/RFdiffusion · AuxiliaryPredictor.py
- RosettaCommons/RFdiffusion · RoseTTAFoldModel.py
A primitive exercise, not an end-to-end reproduction of the named models. No affiliation or endorsement is implied.