Structure confidence heads
Linear pLDDT Head
Free account with email, Google or GitHub. Your code runs in an isolated PyTorch sandbox.
Your task
Produce one unnormalized score per pLDDT local-confidence bin for each atom slot of each token. Higher logits favor their corresponding bins; this head returns those scores. Project the supplied feature vector directly, with bias, to atom/bin logits.
Function signature
plddt_linear_head(
activations: dict,
parameters: dict,
masks: dict,
) -> torch.TensorWorked example
One atom, two confidence bins
For one valid token and atom, let single=[1,3], W_plddt[:,0,:]=[[1,2],[3,-1]], and b_plddt[0,:]=[0.5,-0.5]; both token and atom masks are true. The two returned logits are 1·1 + 3·3 + 0.5 = 10.5 and 1·2 + 3·(-1) - 0.5 = -1.5. These are unnormalized bin scores with output shape (1,1,1,2); confidence reduction happens separately.
Parameters
| Parameter | Shape and meaning |
|---|---|
activationsdict | Supplied intermediate tensors. |
parametersdict | Supplied model parameters, keyed as shown below. |
masksdict | Supplied masks. Each field below defines what True includes or permits. |
Return
torch.Tensor · [B, N, A, L]
Return Predicted logits in atom-slot/bin order.
Required behavior
- single is
[B,N,Cs]; token_mask is[B,N], atom_mask is[B,N,A], and True means present. Sanitize invalid single-token payloads before the learned head. - Use the masked single features directly: no LayerNorm, hidden projection, or activation.
- Project hidden features with
W_{plddt}:[C_s,A,L]and addb_{plddt}:[A,L]. Return[B,N,A,L]in bin-logit order, without softmax or pLDDT scaling. - Zero every output logit whose token is absent or atom slot is absent, including after adding biases. Supply all parameters; do not initialize new layers.
Why this matters
Different heads answer different questions: pLDDT describes local accuracy, a distogram describes distance, and PAE describes error after alignment in a particular residue’s frame. Their probabilities feed separate summaries; they are not interchangeable confidence scales.
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 plddt_linear_head(
activations: dict,
parameters: dict,
masks: dict,
) -> torch.Tensor:
"""Return a tensor with shape (B, N, A, L)."""
# Implement the operation. Inputs and test setup are supplied by BioTorch.
raise NotImplementedError("Implement plddt_linear_head")
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.