As shown in Fig REF , SimCLR is based on a Siamese-like network that learns to congregate different augmented versions of the same image, and separate dissimilar images (negative examples) to learn latent representations.
Given a batch of \(N\)  images, all images are randomly augmented twice to produce \(2 N\)  augmented data points
[1]}. Thus, for any image \(\mathbf {x}\)  in the mini-batch, it has 1 positive example and \(2(N-1)\)  negative examples inside a mini-batch. An encoder \(f_{\theta }\)  together with a projector \(g_{\theta }\)  are used to extract the latent vector that is fed into the loss function, where the encoder representation is \(\mathbf {z} = f_\theta (\mathbf {x})\) , and the projector representation is \(\mathbf {h} = g_\theta (\mathbf {z})\) .
Then the loss function for a positive pair of examples \((t_i(\mathbf {x}), t_j(\mathbf {x}))\)  is defined as:
\(\ell _{t_i, t_j}=-\log \frac{\exp \left(\operatorname{sim}\left(h_{i}, h_{j}\right) / \tau \right)}{\sum _{k=1}^{2 N} \mathbb {1}_{[k \ne i]} \exp \left(\operatorname{sim}\left(h_{i}, h_{k}\right) / \tau \right)}, \text{where } \operatorname{sim}(u, v) = \frac{u^{\top } v}{\Vert u\Vert \Vert v\Vert } \text{ for } u, v\) 
