This repo contains helper functions and skeletons for training ML models in an attempt to avoid repeating code search.
The idea is to have a single repo to refer to for implementation and editing instead of writting from scratch, or utillities that are not easily available.
This is not supposed to be a script repo.
Also installable as a pip module:
pip install git+ssh://git@github.com:AlexBarbera/ML-helper-tools.git
Implementation of specific losses used in cool papers that have no direct implementation.
- Earth-mover distance is a better metric for small permutations in image data compared to
MSELoss. - Original repo
- Uses an encoder network to compare extracted features between target and generated, useful for SuperResolution. paper
- Jitters the image and calculates
MSE. - Used in SR paper
- Maximizes difference between labels rather than set to
1or0. - Docs
- Extracted Cyclegan loss pipeline in case we want to abstract it to somthing different.
- Based on YOLO9000 paper for hierarchical classification.
- Also utility class to use label hierarchy outside of training.
- Smoothes a one-hot vector by taking a bit of the top label and spreading it over the rest of the classes.
- Based on Improved Techniques for training GANs.
- Technically the smoothing would be
$0 \rightarrow \frac{\epsilon}{k}$ and$1 \rightarrow \frac{k-1}{k}$ - While not a loss itself it is a loss wrapper.
Standard models that generally are good to have in hand.
- Unaligned datasets for domain tranformation.
- Original repo
- Classifies differences in latent space of encoder.
- This is mine :)
- Standard ResNet
- Original repo
- ¯\(ツ)/¯
A bunch of standalone functions that are commonly used.
- Allows to easily use distributed training and GPU/TPU usage.
- Pytorch Lightning
- MinMax
- L2-norm
- Tensor to 8bit
- Z-score
- Handles tuples of 3 (anchor [reference], positive [simmilar], negative [different]).
- Matches 2 classes of data in pairs.
- Matches N classes of data in pairs.
- Normalizes images so that covariance
$\sum$ is the Identity matrix leading to decorrelated features. - According to the paper, it should be applied batch-wise.
- Fast Gradient Sign Method paper.
- Pytorch tutorial
- Uses the backward sign to generate noise to disrupt prediction.
- Generally 0.15 is a good delta.
- Iterative FGSM paper.
- Iterates over deltas and predictions to greedely find min solution.
- Iterative Least-Likely Class Method paper
- Iterates the same way as I-FGSM but minimizing the least likely class.