Answers.Body: <p>Using two value and using MSE is probably a better approach. I'd you combine the value to one value, like the case of summation, the network may fits to output 0 on one axis and the value on the other. The method you propose also have the same issue. There are many combination to the real distance, but only one is correct. 
  For a neural network to learn faster, one value will not help it learn faster. Instead, accuracy is often increased if the predicted value is a one hot vector of labels instead of a single value. Hope this can help you.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-22T10:34:19.683Z
Answers.Text: I didn't understand what you mean by this: " the network may fits to output 0 on one axis and the value on the other". and how can the accuracy be increased with one hot encoding? I'm trying to predict continuous values that means accuracy doesn't make sense in this case. Accuracy would make a sense in case of discrete values not continuous values
Answers.UserDisplayName: basilisk
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-22T11:28:08.747Z
Answers.Text: If you use 2 values a and b and you use the (a+b) as the value to compute the loss, there is many different ways that a and b can form a combination, not only the combination (longitude and latitude) you want.
Answers.UserDisplayName: Clement
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-22T11:40:13.477Z
Answers.Text: exactly, that's why I hope that someone can give me a better way to do this because obviously I need to calculate the distance between two coordinates and use it as a loss function otherwise I don't know how my loss should be
Answers.UserDisplayName: basilisk
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-22T12:20:16.043Z
Answers.Text: MSE should work.
Answers.UserDisplayName: Clement
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-22T10:14:28.793Z
Answers.LastActivityDate: 2019-10-22T10:14:28.793Z
Answers.UserDisplayName: Clement
Answers.Body: <p>Alternatively, you might measure the angle between the two vectors (assuming they are points on a sphere), perhaps using their scalar product and use that as the loss function.</p>
  <p><span class="math-container">$a \cdot b = \|a\|\|b\|cos\theta$</span></p>
  <p>(or just use polar co-ordinates)</p>
  <p>An important question is whether the direction of the errors is likely to be uniform or whether errors in particular directions happen more often than others (in which case that needs to be built into the loss function)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-12T15:25:46.453Z
Answers.LastActivityDate: 2021-08-12T16:04:56.373Z
Answers.LastEditDate: 2021-08-12T16:04:56.373Z
Answers.UserDisplayName: Dikran Marsupial
Body: <p>I'm using a neural network to solve a multi regression problem because I'm trying to predict continuous values. To be more specific, I'm making a tracking algorithm to track the position of an object, I'm trying to predict two values, the latitude and longitude of an object.</p>
  <p>Now, to calculate the loss of the model, there are some common functions, like mean squared error or mean absolute error, etc., but I'm wondering if I can use some custom function, like <a href="https://en.wikipedia.org/wiki/Haversine_formula" rel="nofollow noreferrer">this</a>, to calculate the distance between the two longitude and latitude values, and then the loss would be the difference between the real distance (calculated from the real longitude and latitude) and the predicted distance (calculated from the predicted longitude and latitude). These are some thoughts from me, so I'm wondering if such an idea would make sense?</p>
  <p>Would this work in my case better than using the mean squared error as a loss function?</p>
  <p>I had another question in mind. In my case, I'm predicting two values (longitude and latitude), but is there a way to transform these two target values to only one value so that my neural network can learn better and faster? If yes, which method should I use? Should I calculate the summation of the two and make that as a new target? Does this make sense?</p>
  
Tags: <neural-networks><deep-learning><python><objective-functions><regression>
Title: When should I create a custom loss function?
UserDisplayName: basilisk
ThreadText: # When should I create a custom loss function?
  
  (Asked by: username_0 on 2019-10-22)
  
  I'm using a neural network to solve a multi regression problem because I'm trying to predict continuous values. To be more specific, I'm making a tracking algorithm to track the position of an object, I'm trying to predict two values, the latitude and longitude of an object.
  
  Now, to calculate the loss of the model, there are some common functions, like mean squared error or mean absolute error, etc., but I'm wondering if I can use some custom function, like [this](https://en.wikipedia.org/wiki/Haversine_formula), to calculate the distance between the two longitude and latitude values, and then the loss would be the difference between the real distance (calculated from the real longitude and latitude) and the predicted distance (calculated from the predicted longitude and latitude). These are some thoughts from me, so I'm wondering if such an idea would make sense?
  
  Would this work in my case better than using the mean squared error as a loss function?
  
  I had another question in mind. In my case, I'm predicting two values (longitude and latitude), but is there a way to transform these two target values to only one value so that my neural network can learn better and faster? If yes, which method should I use? Should I calculate the summation of the two and make that as a new target? Does this make sense?
  
  **Tags:** neural-networks, deep-learning, python, objective-functions, regression
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-10-22. Score: 1
  
  Using two value and using MSE is probably a better approach. I'd you combine the value to one value, like the case of summation, the network may fits to output 0 on one axis and the value on the other. The method you propose also have the same issue. There are many combination to the real distance, but only one is correct.
  For a neural network to learn faster, one value will not help it learn faster. Instead, accuracy is often increased if the predicted value is a one hot vector of labels instead of a single value. Hope this can help you.
  
  > **Comments:**
  > **username_0**: I didn't understand what you mean by this: " the network may fits to output 0 on one axis and the value on the other". and how can the accuracy be increased with one hot encoding? I'm trying to predict continuous values that means accuracy doesn't make sense in this case. Accuracy would make a sense in case of discrete values not continuous values  
  > **username_1**: If you use 2 values a and b and you use the (a+b) as the value to compute the loss, there is many different ways that a and b can form a combination, not only the combination (longitude and latitude) you want.  
  > **username_0**: exactly, that's why I hope that someone can give me a better way to do this because obviously I need to calculate the distance between two coordinates and use it as a loss function otherwise I don't know how my loss should be  
  > **username_1**: MSE should work.  
  
  ---
  
  ### Answer by username_2 on 2021-08-12. Score: 0
  
  Alternatively, you might measure the angle between the two vectors (assuming they are points on a sphere), perhaps using their scalar product and use that as the loss function.
  
  $a \cdot b = \|a\|\|b\|cos\theta$
  
  (or just use polar co-ordinates)
  
  An important question is whether the direction of the errors is likely to be uniform or whether errors in particular directions happen more often than others (in which case that needs to be built into the loss function)
  
  
  ---
  
  