This repository focuses on a masked autoencoder based on a Convolutional Neural Network (CNN). Initially, it is used for self-supervised learning to extract features from the MNIST dataset by reconstructing masked images. Subsequently, the encoder of the network is employed for downstream classification tasks. After fine-tuning, it yields remarkable results.
The design involves two stages of work. In the first stage, the model masks the input image and pretrains an autoencoder to reconstruct it. In the second stage, a pretrained encoder is used to encode the full image, with its parameters frozen, and a classification network is trained.
Pretrain the masked autoencoder moedel 100 epochs, save the loss curve and visualize reconstruction process.
Finetune the pretrain encoder, save the loss and model score curve. Show a model classify sample.
cd CNN_Masked_Autoencoder
pip install -r requirements.txt
python pretrain.py
python finetune.py
python analyze.py
NOTE:
- It will auto download the dataset.
- Model will save in
./ckpt/pretrain
and./ckpt/finetune
. - In
./figure
floder you can see analyze img.