Reduce same sample distance in VAE encodings

I'm working on a beta VAE model learning a latent representation used as a similarity metric for image registration.

One of the main problems I'm facing is that the encoder + sampler output doesn't fulfill the requirements for a mathematical metric (https://en.wikipedia.org/wiki/Metric_(mathematics)) - is there a known way of how to decrease same-sample distance after encoding + sampling as well as promoting transitivity (triangle inequality) and symmetry?

• "One of the main problems I'm facing is that the encoder + sampler output doesn't fulfill the requirements for a mathematical metric", isn't the output just a number or vector? Can you be more specific: why can't the output of the encoder or decoder be used by a metric? – nbro Nov 18 '19 at 12:43
• The distance between samples drawn from the distribution defined by the encoded input isn't a metric as it doesn't fulfill the requirements of a mathematical metric as listed here:en.wikipedia.org/wiki/Metric_(mathematics) I would like to transform the model in such a way that this is possible, or would like to dinf out about any other options to achieve the same effect. – hechth Nov 18 '19 at 13:49
• You're not specifying which metric you are using. You could be using the Euclidean metric, which is a metric. – nbro Nov 18 '19 at 15:30
• If I have a "function" g(x) for which g(x) = g(x) doesn't hold, because it includes a random process like sampling, then f(g(x)) is not necessarily a metric with regards to x even if f is a metric. If g is a function drawing a random sample which depends on the input, for example it samples a uniform distribution between x-1 and x+1, then f(g(x)) is no more a metric because it could be anything from f(x-1) to f(x+1). – hechth Nov 18 '19 at 17:06
• The metric has nothing to do with your stochastic operations. For a given arbitrary (same) $x$, then if the function $d$ satisfies the properties that make it a metric (such as $d(x, x) = 0$ if $x=x$), then it will be a metric. Of course, for different inputs, the metric may produce different results, but this is not the problem of the metric. To be clear, in your example $x_i \neq x_j$, for $i \neq j$. Then $d(x_i, x_j) > 0$. In your specific case, the inputs are, in fact, different and are different every time because they depend on a stochastic element. – nbro Nov 18 '19 at 17:21