Answers.Body: <p>There is no right answer to this. Finding the right loss function is a tough and difficult problem. So your goal as the architect is to try to find one that best suits your needs. So lets think about your needs.  </p>
  
  <p>You mention that you dont want lighting shifts to cause large error, so ill take a leap and assume you care more about the shapes and style of the image more than the coloring. To deal with this, maybe consider using difference of the gram matrices (this is considered common place in style transfer literature: <a href="https://arxiv.org/pdf/1508.06576.pdf" rel="nofollow noreferrer">A Neural Algorithm of Artistic Style</a>) Note that you could use the encoder to get the representation of the output as well for the loss, <span class="math-container">$L(x) = D(Gram(Enc(x)), Gram(Enc(\hat x))$</span> where <span class="math-container">$D$</span> would be some distance metric like euclidian distance.  </p>
  
  <p>Maybe the outline is all you care about. You could use some known edge detector filter and compare those, ex: <span class="math-container">$D(Edge(x), Edge(\hat x))$</span>  </p>
  
  <p>Maybe you just dont care about color shifts, you could do <span class="math-container">$D(x - \mu_x, \hat x - \mu_{\hat x}$</span>).  </p>
  
  <p>Note that you can play around with whatever distance metric you use, whether it be with MSE, RMSE, MAE, etc... Each has their own small pros/cons based on the loss manifolds they create. In your case i dont think the difference there will be night and day though, but you never know.</p>
  
  <p>Also mixing and matching is always nice: ex: <span class="math-container">$L(x) = \lambda_1 D(x, \hat x) + \lambda_2D(Gram(Enc(x)), Gram(Enc(\hat x)) + ...$</span>  </p>
  
  <p><strong>Takeaway:</strong> MSE might actually be fine, but it really depends on what <strong>you</strong> prioritize, and once you figure that out you can start getting clever and design the loss that fits your needs and problem</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-11T18:04:32.447Z
Answers.LastActivityDate: 2019-07-11T18:04:32.447Z
Answers.UserDisplayName: mshlis
Body: <p>What is the best choice for loss function in Convolution Neural Network and in Autoencoder in particular - and why?</p>
  
  <p>I understand that the MSE is probably not the best choice, because little difference in lighting can cause a big difference in end loss. </p>
  
  <p>What about Binary cross-entropy? As I understand, this should be used when target vector is composed as 1 at one place and 0 at all others, so you compare only class that should be correct (and ignore others),... But this is an image (although the values are converted in 0-1 values,...)</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-11T17:12:47.807Z
Comments.Text: Hi. Can you just focus on one model? Please, edit your question and ask just about one model, otherwise, this question might become too broad.
Comments.UserDisplayName: nbro
Tags: <convolutional-neural-networks><objective-functions><autoencoders>
Title: What is the best loss function for convolution neural network and autoencoder?
UserDisplayName: Marko Zadravec
ThreadText: # What is the best loss function for convolution neural network and autoencoder?
  
  (Asked by: username_0 on 2019-07-11)
  
  What is the best choice for loss function in Convolution Neural Network and in Autoencoder in particular - and why?
  
  I understand that the MSE is probably not the best choice, because little difference in lighting can cause a big difference in end loss.
  
  What about Binary cross-entropy? As I understand, this should be used when target vector is composed as 1 at one place and 0 at all others, so you compare only class that should be correct (and ignore others),... But this is an image (although the values are converted in 0-1 values,...)
  
  **Tags:** convolutional-neural-networks, objective-functions, autoencoders
  
  > **Comments:**
  > **username_1**: Hi. Can you just focus on one model? Please, edit your question and ask just about one model, otherwise, this question might become too broad.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-07-11. Score: 1
  
  There is no right answer to this. Finding the right loss function is a tough and difficult problem. So your goal as the architect is to try to find one that best suits your needs. So lets think about your needs.
  
  You mention that you dont want lighting shifts to cause large error, so ill take a leap and assume you care more about the shapes and style of the image more than the coloring. To deal with this, maybe consider using difference of the gram matrices (this is considered common place in style transfer literature: [A Neural Algorithm of Artistic Style](https://arxiv.org/pdf/1508.06576.pdf)) Note that you could use the encoder to get the representation of the output as well for the loss, $L(x) = D(Gram(Enc(x)), Gram(Enc(\hat x))$ where $D$ would be some distance metric like euclidian distance.
  
  Maybe the outline is all you care about. You could use some known edge detector filter and compare those, ex: $D(Edge(x), Edge(\hat x))$
  
  Maybe you just dont care about color shifts, you could do $D(x - \mu\_x, \hat x - \mu\_{\hat x}$).
  
  Note that you can play around with whatever distance metric you use, whether it be with MSE, RMSE, MAE, etc... Each has their own small pros/cons based on the loss manifolds they create. In your case i dont think the difference there will be night and day though, but you never know.
  
  Also mixing and matching is always nice: ex: $L(x) = \lambda\_1 D(x, \hat x) + \lambda\_2D(Gram(Enc(x)), Gram(Enc(\hat x)) + ...$
  
  **Takeaway:** MSE might actually be fine, but it really depends on what **you** prioritize, and once you figure that out you can start getting clever and design the loss that fits your needs and problem
  
  
  ---
  
  