A Self-Encoder for Learning Nearest Neighbors