link to paper: https://github.com/artenyx/self-supervised-learning/blob/main/Thesis_Paper.pdf
This repo can be used for running self-supervised learning experiments. There are three main architectures that can be run from the notebook:
- Autoencoder
- "Denoising" Autoencoder
- SimCLR Encoder
Both of the autoencoder structures can be trained with a "parallel" architecture, where two image augmentations are run through the network and a reconstruction loss is placed on their embeddings.
For all experiments, a simple Conv6 network spelled out by (Yali paper citation) is used as an encoder. The networks can also be trained in a layer-wise fashion, which changes which decoder is used. In a non-layer-wise setting, the decoder is simpler, though in the layer-wise setting, the decoder must be symmetric to the encoder so a more complex decoder must be used.
All experiments consist of 2 stages:
- Unsupervised representation learning: Architecture of choice is run in an unsupervised fashion in order to orient the network towards a quality embedding space
- Evaluation stage: New dataset is embedded and tested via Linear Evaluation or k-means clustering.
By default, experiments are run with 400 epochs of representation learning, 300 epochs of linear evaluation with learning rates of 0.0001 and 0.001, respectively. Experiment conditions (usl epochs, le epochs, learning rates, etc.) can be configured through command line parser on any experiment.
This experiment type is a single denoising autoencoder, meaning that if
The idea behind this network architecture is that the network is forced to learn the "true" representation of the data by learning what how the augmentations warp the input space and reversing it.
(ADD FIGURE)
To run this experiment, use the following code:
python main.py --usl_type ae_single --denoisingIn this type of self-supervised learning, two augmentations of the same image are passed through the autoencoder between
each gradient step. After the two images are run through the autoencoder, the loss function is the sum of the reconstruction losses plus a
term that penalizes the distance between the two embeddings. Generally, this loss function is an MSE loss, though it can
also be run as an L1 or even SimCLR or Barlow Twins loss on the image embeddings. This type of experiment introduces
the hyperparameter
Alpha is run at orders of magnitude between 0.00001 and 10. Results are presented in the results section.
To run this experiment at a specific alpha value, use the following code:
python main.py --usl_type ae_parallel --denoising --alpha *ALPHA VALUE*This architecture combines the first two, running a denoising autoencoder with the parallel loss function and a penalty on the embeddings. The loss used in the notebook for this architecture is as follows:
To run this experiment, use the following code:
python main.py --usl_type ae_parallel --denoising --alpha *ALPHA VALUE*This experiment is conducted in accordance with (SIMCLR PAPER). Unlike the autoencoder experiments, here there is no decoder in the trained network, only an encoder and a projection layer. Like previously, two image augmentations are fed through the network, where "positives" are augmentations of the same image and "negatives" are augmentations of different images. The SimCLR loss function then incentivizes the network to embed positives "near" each other and negatives "far" from each other. The loss function uses the Noise Contrastive Estimation loss across each batch. Its formulation can be seen in the paper.
To run this experiment, use the following code:
python main.py --usl_type simclrTo run this experiment, use the following code:
python main.py --exp_type alpha --usl_type ae_parallel --denoisingThe effect of augmentation strength can be run in any of the aforementioned experiments. Thus the strength experiment function is a function that wraps a separate experiment function. Thus any experiment can be run normally, and if the argument --strength_exp is set to True, the experiment will be completed 5 times at strengths [0, 0.25, 0.5, 0.75, 1]. Here is an example call of this type of experiment:
python main.py --exp_type strength --usl_type ae_parallel --denoising --alpha 0.1This call will run a parallel denoising autoencoder 5 times at the various strengths.