Question 1: Short answer
mediumAI-checkedPyTorchA batch holds images x and their augmented copies x_pos. For row i, x_pos[i] is the
positive and the other rows of x_pos are its negatives:
z1 = F.normalize(f(x), dim=1) # (b, d)
z2 = F.normalize(f(x_pos), dim=1) # (b, d)
logits = z1 @ z2.T / tau # (b, b)
Complete the loss: loss = F.cross_entropy(logits, torch.(b))
Fill in every blank (hints in the boxes). Enter moves to the next blank.