How to build an encoder using a distance matrix
This is essentially what t-SNE does. It supports transforming data from any input dimension to any output dimension, and it tries to preserve distances between all pairs of points.

From the author's website:


  Can I use a pairwise Euclidean distance matrix as input into t-SNE?
  
  Yes you can! Download the Matlab implementation, and use your pairwise
  Euclidean distance matrix as input into the tsne_d.m function.