Convolution blocks
The encoder applies four convolution stages with intermittent max pooling. This progressively reduces spatial resolution while expanding channel depth.
Architecture chapter
Shared encoder path, embedding projection, comparison logic, and output scoring.
Module boundary
The repository keeps all model definition logic inside `model.py`. The `Siamese` class exposes `forward_one` for single-branch feature extraction and `forward` for pairwise scoring.
Encoder path
The encoder applies four convolution stages with intermittent max pooling. This progressively reduces spatial resolution while expanding channel depth.
Both input images pass through the same `self.conv` and `self.liner` modules, ensuring that similarity is measured in a common embedding space.
Control flow
Each branch image is encoded by the convolution stack, flattened, and projected into a 4096-dimensional embedding with sigmoid activation.
`forward` computes `torch.abs(out1 - out2)`, which is the central similarity comparison primitive in this implementation.
The difference vector is passed to `self.out`, producing a single logit for binary same-class vs different-class classification.
Current limitations
The architecture is compact and easy to read, but the file does not separate encoder, projection, and scoring into independently testable modules.
The model returns logits directly and leaves probability calibration to the loss function and downstream evaluation code.