Neural Network Loss Function - Mean Square Error: questions about what 'n' signifies I'm very new to neural networks and have recently learnt about the loss functions used with neural networks.
This question is in regards to the mean square error metric, defined as (from the textbook I'm using):
$(\frac{1}{n})\sum_{i=1}^{n}(h_{\theta}(x^{i}) - y^{i})^{2}$
Where $h_{\theta}(x^{i})$ gives the predicted value for $x^{i}$ with model’s weights $\theta$ and $y^{i}$ represents the actual prediction for the data point at index $i$.
Looking up about this function online, I've seen different sources say different things. I can't seem to work out what n actually represents.
I understood it as representing the number of neurons in the output layer and hence you'd just be finding the difference between the actual neuron value and the predicted value of the network given the weights.
Some of the sources say it represents the number of training samples. If this is the case however, what does $h_{\theta}(x^{i})$ represent? Is it a sum of the output neuron values itself? Also if n is this, wouldn't that mean you'd have to run the function many times over all the training samples to minimize it? Whereas with the previous understanding of n, you could run it on certain samples and not all of them.
First, try to understand a few points -

Output Neuron value and the prediction both are the same things. In the case of Classification, we convert the output probability to Class based on a Threshold.

MSE is used in Regression and In a regression problem, you mostly have one output Neuron e.g. Price. You may have more if you want to club multiple targets e.g. Bounding Box problem


The &quot;N&quot; in the denominator is the number of different errors calculated which is basically the number of samples in context.
With &quot;In context&quot;, I meant if it's at the time of backpropagation it is the batch_size. if it's at the end of epoch/training it's the whole training dataset.

what does $h_θ(x^i)$ represent?

It is the prediction(value of output Neuron) for $i_{th}$ sample.