For the Construction of Deep Learning Models
Backbone Deep Learning models which can be applied to a variety of deep learning tasks (including facial recognition) have been implemented in a range of libraries available in Python. I'm assuming by constructing your own algorithm you mean a novel implementation of the model structure. Taking the PyTorch framework as an example, some common pretrained models are available here:
https://github.com/pytorch/vision/tree/master/torchvision/models
To train a novel face recognition model you could follow the tutorial for object detection available here:
https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html
and make changes to the model.
In the tutorial they use model features from the library in the following section of code:
# load a pre-trained model for classification and return
# only the features
backbone = torchvision.models.mobilenet_v2(pretrained=True).features
For the simplest example torchvision.models.AlexNet.features look like this:
self.features = nn.Sequential(
nn.Conv2d(3, 64, kernel_size=11, stride=4, padding=2),
nn.ReLU(inplace=True),
nn.MaxPool2d(kernel_size=3, stride=2),
nn.Conv2d(64, 192, kernel_size=5, padding=2),
nn.ReLU(inplace=True),
nn.MaxPool2d(kernel_size=3, stride=2),
nn.Conv2d(192, 384, kernel_size=3, padding=1),
nn.ReLU(inplace=True),
nn.Conv2d(384, 256, kernel_size=3, padding=1),
nn.ReLU(inplace=True),
nn.Conv2d(256, 256, kernel_size=3, padding=1),
nn.ReLU(inplace=True),
nn.MaxPool2d(kernel_size=3, stride=2),
)
Adding or subtracting layers from this backbone feature extractor would result in a new "algorithm" for object detection.
If you want to know exactly what mathematical operation each of these layers is performing you can look at the PyTorch documentation. For example, in the case of nn.Relu layer:
https://pytorch.org/docs/stable/generated/torch.nn.ReLU.html
Applies the rectified linear unit function element-wise:
$$ ReLU(x)=(x)^{+}=max(0,x)$$