Skip to content

zhan1182/autoencoder-kNN

Repository files navigation

Learning a Neighborhood Preserving Embedding by Convolutional Autoencoder

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.

Requirements

  1. Python 3
  2. Tensorflow
  3. Scipy
  4. Numpy
  5. h5py
  6. matplotlib
  7. scikit-learn (optional)
  8. metric_learn (optional)
  9. Keras (optional)

Scripts

  1. cae_mnist.py
  • A tensorflow implementation of Contractive autoencoder for comparison.
  1. cnn_mnist.py
  • A keras implementation of Convolutional autoencoder for comparison.
  1. knn.py
  • A vector implementation of KNN algorithm. A large memory is needed if traning on the whole dataset.
  1. nca_knn.py
  • Learn a linear transformation in order to improve KNN accuracy. Require too much memory in practical.
  1. pca.py
  • Show PCA and CNN-NCA compressed data points in 2D respectively.
  1. setup.py
  • Setup the current directory for running these scripts.
  1. tf_mnist.py
  • A tensorflow implementation of CNN-NCA.
  1. tf_pretrain.py
  • Pretrain the model to learn a good representation.
  1. tf_train.py
  • Fine-tune the model to favor KNN algorithm.

How to run

python setup.py
python tf_pretrain.py
python tf_train.py
python knn.py

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages