Large-Margin kNN Classification Using a Deep Encoder Network