Body: <p>I'm working on a beta VAE model learning a latent representation used as a similarity metric for image registration.</p>
  
  <p>One of the main problems I'm facing is that the encoder + sampler output doesn't fulfill the requirements for a mathematical metric (<a href="https://en.wikipedia.org/wiki/Metric_(mathematics)" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Metric_(mathematics)</a>) - is there a known way of how to decrease same-sample distance after encoding + sampling as well as promoting transitivity (triangle inequality) and symmetry?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-18T12:43:07.283Z
Comments.Text: "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?
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-18T13:49:04.733Z
Comments.Text: 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:https://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.
Comments.UserDisplayName: hechth
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-18T15:30:26.900Z
Comments.Text: You're not specifying which metric you are using. You could be using the Euclidean metric, which is a metric.
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-18T17:06:53.687Z
Comments.Text: 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).
Comments.UserDisplayName: hechth
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-18T17:21:15.310Z
Comments.Text: 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.
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-19T06:56:28.807Z
Comments.Text: Exactly, the inputs to the metric f produced by function g are different. Now my question is how I can force the encoder which approximates or computes function g to learn g in such a way that g and afterwards the concatenation with f form a metric.
Comments.UserDisplayName: hechth
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-19T15:26:08.960Z
Comments.Text: You need to avoid any stochastic operation or keep track of them so that later you can compare the outputs of the encoder or decoder by taking into account the stochasticity (i.e. you remove the stochasticity element from the outputs before comparing). I don't really know if this is feasible. Maybe it also depends on your implementation of the VAE.
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-19T15:52:35.993Z
Comments.Text: Well it's hard to avoid stochastic operations in a VAE since that's one of the core elements.
  One solution I'm currently experimenting with is to instead of comparing the samples drawn from distributions for x and y to compare the distributions directly using a metric like symmetric KL divergence.
Comments.UserDisplayName: hechth
Tags: <autoencoders><variational-autoencoder>
Title: Reduce same sample distance in VAE encodings
UserDisplayName: hechth
ThreadText: # Reduce same sample distance in VAE encodings
  
  (Asked by: username_0 on 2019-11-18)
  
  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?
  
  **Tags:** autoencoders, variational-autoencoder
  
  > **Comments:**
  > **username_1**: "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?  
  > **username_0**: 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:https://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.  
  > **username_1**: You're not specifying which metric you are using. You could be using the Euclidean metric, which is a metric.  
  > **username_0**: 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).  
  > **username_1**: 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.  
  > **username_0**: Exactly, the inputs to the metric f produced by function g are different. Now my question is how I can force the encoder which approximates or computes function g to learn g in such a way that g and afterwards the concatenation with f form a metric.  
  > **username_1**: You need to avoid any stochastic operation or keep track of them so that later you can compare the outputs of the encoder or decoder by taking into account the stochasticity (i.e. you remove the stochasticity element from the outputs before comparing). I don't really know if this is feasible. Maybe it also depends on your implementation of the VAE.  
  > **username_0**: Well it's hard to avoid stochastic operations in a VAE since that's one of the core elements. One solution I'm currently experimenting with is to instead of comparing the samples drawn from distributions for x and y to compare the distributions directly using a metric like symmetric KL divergence.  
  
  ---
  
  ## 0 answers
  
  