# Metric Embedding Learning on Multi-Directional Projections
## 4 Results
### Discriminative Ability  
The popular MNIST dataset [58] contains images of handwritten digits, with image sizes fixed in \(28\times 28\). For 60,000 pre-selected training images, 10,000 test images are also provided. The EMNIST (extended MNIST) dataset [59] also includes letter representations among the digits, therefore, the number of categories is increased, while image size is reduced to \(28\times 28\). The data of both MNIST and EMNIST originates from the NIST dataset [49]. This database contains the data from 3669 handwritten forms, where digits and letters are segmented, labeled, and transformed to a \(128\times 128\) size. The total number of characters is 814,255. For the first experiments, the NIST dataset was applied. While the set contains imbalance between the classes regarding the number of samples, this will be handled during training by selecting a subset of samples with an equal size from each classes. As recommended by the dataset descriptor [49], extracted records from handwriting sample form nr. 4 is selected as the validation set. As a preprocessing step, the original images are cropped, the region of interest is highlighted, and they are extended to be square. Before MDIPFL transformed images are inverted, the result is images where the background pixel intensities are zeros, and foreground content information is represented as positive integers. Samples are shown on Figure 6.  
As an overall experiment, multiple setups are examined, including the original NIST datarecords with size \(128\times 128\), the cropped images resized to \(96\times 96\), and the results of the MDIPFL transform that are sized \(50\times 37\). The neural architectures applied are custom CNNs, where the design decisions are inspired by the VGG architectures [24]. The selected encoding vector length is 64. The structures are constructed so the number of trainable parameters are similar, around \(6M\), in the case of the original NIST set, \(9M\). For training, 1500 images from a total of 62 classes are selected. Where multi-class classification pretraining is applied, a maximum of 10 epochs are done with 100 steps per epoch, and 32 samples in each step. During training, a maximum number of 1000 iterations with 500 steps is set. If, however, convergence fails for 10 consecutive steps, training is shut down. As the optimizer, the novel rectified Adam algorithm [60] is applied. The architectures were implemented in Keras [61] over Tensorflow [62], and by using the EmbeddingNet framework [54]. In the spirit of open access and reproducible results, the source  
Figure 6: Samples of the NIST dataset before and after content highlighting, and MDIPFL transformation. Subfigures (**a**,**b**) represent character lowercase \(e\). Subfigure (**c**) shows a sample of lowercase \(x\). codes (including a batch of useful scripts), configurations, and result logs are made publicly available at [[https://github.com/kerteszg/EmbeddingNet](https://github.com/kerteszg/EmbeddingNet)]([https://github.com/kerteszg/EmbeddingNet](https://github.com/kerteszg/EmbeddingNet)) as supplementary materials. Table 1 presents the measured one-shot classification accuracy of each method on the validation subset. Based on the results, multiple conclusions can be done. Firstly, embedding learning in MDIPFL space is feasible as the learned representations are suitable for discrimination. Furthermore, the application of few epochs of multi-class pretraining have a stabilizing effect on performance. Results also show, that Siamese architectures outperform the presented triplet-based structures. The possible cause of this phenomenon is the relatively small number of classes, where calculated contrastive loss is more effective than the triplet loss technique. As the measured triplet loss fails to improve over time, early stopping shuts down training and results in a suboptimal learning of embedding vectors. On Figure 7, the evolution of the measured loss during training is visualized.