Answers.Body: <p>You'd just sum the losses over each of the dimensions.</p>
  <p>If your model outputs a vector of size <span class="math-container">$d$</span>, it's functionally the same as if you had a model that outputs <span class="math-container">$d$</span> different outputs, with <span class="math-container">$d$</span> different labels.</p>
  <p>If you had <span class="math-container">$d$</span> labels, for some loss <span class="math-container">$L$</span>:
  <span class="math-container">$$\sum_{i\ \in\ [1 .. d]} \frac{1}{n} \sum_{j\ \in\ [1..n]} \mathcal{L}(Y_{j,i}, \hat{Y}_{j,i}) = \frac{1}{n} \sum_{j\ \in\ [1..n]} \sum_{i\ \in\ [1 .. d]} \mathcal{L}(Y_{j,i}, \hat{Y}_{j,i})$$</span></p>
  <p><a href="https://arxiv.org/abs/1511.08861" rel="nofollow noreferrer">You can see this, for example, for image generation tasks, where both the target and the prediction are matrices.</a> For each image prediction, they average the loss over each of the pixels.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-10-08T01:34:37.673Z
Answers.LastActivityDate: 2023-10-08T01:34:37.673Z
Answers.UserDisplayName: Alexander Wan
Body: <p>What are the formulas for the MAE , MSE  when output is a vector?</p>
  <p>MAE: Mean Absolute Error</p>
  <p>MSE: Mean squared error</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-10-07T06:56:32.787Z
Comments.Text: By output, do you mean the output of your model? And I'm assuming the label would be a similarly shaped vector as well?
Comments.UserDisplayName: Alexander Wan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-10-07T19:17:28.027Z
Comments.Text: yes, i mean the output of the model (and yes label is a vector also).
Comments.UserDisplayName: DSPinfinity
Tags: <machine-learning><linear-algebra>
Title: What are the formulas for the MAE , MSE when output is a vector?
UserDisplayName: DSPinfinity
ThreadText: # What are the formulas for the MAE , MSE when output is a vector?
  
  (Asked by: username_0 on 2023-10-06)
  
  What are the formulas for the MAE , MSE when output is a vector?
  
  MAE: Mean Absolute Error
  
  MSE: Mean squared error
  
  **Tags:** machine-learning, linear-algebra
  
  > **Comments:**
  > **username_1**: By output, do you mean the output of your model? And I'm assuming the label would be a similarly shaped vector as well?  
  > **username_0**: yes, i mean the output of the model (and yes label is a vector also).  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-10-08. Score: 1 | Accepted answer
  
  You'd just sum the losses over each of the dimensions.
  
  If your model outputs a vector of size $d$, it's functionally the same as if you had a model that outputs $d$ different outputs, with $d$ different labels.
  
  If you had $d$ labels, for some loss $L$:
  $$\sum\_{i\ \in\ [1 .. d]} \frac{1}{n} \sum\_{j\ \in\ [1..n]} \mathcal{L}(Y\_{j,i}, \hat{Y}\_{j,i}) = \frac{1}{n} \sum\_{j\ \in\ [1..n]} \sum\_{i\ \in\ [1 .. d]} \mathcal{L}(Y\_{j,i}, \hat{Y}\_{j,i})$$
  
  [You can see this, for example, for image generation tasks, where both the target and the prediction are matrices.](https://arxiv.org/abs/1511.08861) For each image prediction, they average the loss over each of the pixels.
  
  
  ---
  
  