Structure confidence heads

Linear pLDDT Head

EasyRaw PyTorchAbout 10 min1 public example plus private tests

RFdiffusion

Write and run your solution Sign in

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.Tensor

Worked 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

ParameterShape and meaning
activationsdictSupplied intermediate tensors.
parametersdictSupplied model parameters, keyed as shown below.
masksdictSupplied 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 add b_{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.

Write and run your solution Sign in

Free account with email, Google or GitHub. Your code runs in an isolated PyTorch sandbox.

Related exercises

Sources and further reading

A primitive exercise, not an end-to-end reproduction of the named models. No affiliation or endorsement is implied.