In this project, I aim to learn a non-linear encoding function that projects image data samples from the high-dimensional input space to a low-dimensional feature space by a convolutional autoencoder. During the compression, the encoding function preserves the latent neighborhood structure in the input data. Therefore, the K-nearest neighbor classification algorithm performs well in the feature space. I test the method on the MNIST handwritten digits. The network is implemented in pure Tensorflow and I denote the system as CNN-NCA.
- Python 3
- Tensorflow
- Scipy
- Numpy
- h5py
- matplotlib
- scikit-learn (optional)
- metric_learn (optional)
- Keras (optional)
- cae_mnist.py
- A tensorflow implementation of Contractive autoencoder for comparison.
- cnn_mnist.py
- A keras implementation of Convolutional autoencoder for comparison.
- knn.py
- A vector implementation of KNN algorithm. A large memory is needed if traning on the whole dataset.
- nca_knn.py
- Learn a linear transformation in order to improve KNN accuracy. Require too much memory in practical.
- pca.py
- Show PCA and CNN-NCA compressed data points in 2D respectively.
- setup.py
- Setup the current directory for running these scripts.
- tf_mnist.py
- A tensorflow implementation of CNN-NCA.
- tf_pretrain.py
- Pretrain the model to learn a good representation.
- tf_train.py
- Fine-tune the model to favor KNN algorithm.
python setup.py
python tf_pretrain.py
python tf_train.py
python knn.py