Answers.Body: <p>If the <strong>accuracy is sky-rocketing</strong> unexpectedly during training (and then dropping immediately), my first hunch would be to experiment with the learning rate - <strong>it seems that the learning rate may be too high</strong>. Please remember that the learning rate is just a parameter that magnifies your step in the direction of the gradient calculated at point (t). It means that in (the case of first-order optimization) there is nothing that prohibits it from overshooting the local or global minimum.</p>
  <p>The second thing that I would like to inspect is the <strong>architecture of the network</strong>. Given that you have 100 inputs and then only 10 neurons, it is very likely that the architecture is just too simple to approximate the target function. However, this seems strange, as you are trying to approximate the sine, linear and quadratic functions. This should be feasible by using a rather simple architecture. I omit here a detailed explanation of the approximation of common functions. If you are interested, jump straight into an approximation of common polynomials and the minimum number of parameters required to do so.</p>
  <p>Finally, I wonder about your samples. You say that you generate some common functions and then sample points that serve as training data. Please keep in mind, that your sample should be reflective of the data-generating function. If it not (e.g. you sample only around some small interval) - you will not approximate the function correctly, even if your acc is 100% ;)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-09-05T08:12:58.300Z
Answers.LastActivityDate: 2023-09-05T08:12:58.300Z
Answers.UserDisplayName: Scolpe
Answers.Body: <p>Your network is always guessing the same output. I would recommend using cross-entropy loss rather than mean-squared error.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-06-01T13:10:54.380Z
Answers.LastActivityDate: 2024-06-01T13:10:54.380Z
Answers.UserDisplayName: programjames
Answers.Body: <p>One cause I can think of is that your network is too simple for the task. That would explain why the  cost stops decreasing at around 0.33. Your network might be outputting the same prediction independent of the input, by using the bias values and setting the weights to low values. That would also be the reason why the accuracy is 0.33, because one third of the time the network is lucky and its guess matches the input.</p>
  <p>Another problem could be your that you are using a bad model architecture, for example using the wrong activation function. I suggest using the relu or the sigmoid function.</p>
  <p>I hope you are able to solve your problem.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-04-08T00:26:36.617Z
Answers.LastActivityDate: 2023-04-08T00:32:08.150Z
Answers.LastEditDate: 2023-04-08T00:32:08.150Z
Answers.UserDisplayName: lev1248
Body: <p>I'm testing my own implementation of a neural network on recognising the type of a function. I generate sine, linear and quadratic functions with random parameters, compute their values for a linspace of size 100 and pass the y-values as input into the network, expecting a vector size 3 as the output.</p>
  <p>I've already checked my gradient with the one returned by the numdiff library and it's spot on. The input is normalized.</p>
  <p>The structure of the neural network is 100 nodes in the input layer, 10 nodes in the hidden layer and 3 nodes in the output layer. These are the results I got for 200 epochs with batch size 20, learning rate of 0.001 and 400 training samples:</p>
  <p><a href="https://i.sstatic.net/TSS1S.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/TSS1S.png" alt="enter image description here" /></a></p>
  <p>The cost (E_mean) is decreasing but the accuracy on training data isn't. What happened too was that the accuracy has sky-rocketed but then dropped immediately.</p>
  <p>I'd be grateful for any help!</p>
  
Tags: <neural-networks><accuracy>
Title: Why does the accuracy of my neural network stay constant?
UserDisplayName: Šimon Bláha
ThreadText: # Why does the accuracy of my neural network stay constant?
  
  (Asked by: username_0 on 2023-04-07)
  
  I'm testing my own implementation of a neural network on recognising the type of a function. I generate sine, linear and quadratic functions with random parameters, compute their values for a linspace of size 100 and pass the y-values as input into the network, expecting a vector size 3 as the output.
  
  I've already checked my gradient with the one returned by the numdiff library and it's spot on. The input is normalized.
  
  The structure of the neural network is 100 nodes in the input layer, 10 nodes in the hidden layer and 3 nodes in the output layer. These are the results I got for 200 epochs with batch size 20, learning rate of 0.001 and 400 training samples:
  
  [![enter image description here](https://i.sstatic.net/TSS1S.png)](https://i.sstatic.net/TSS1S.png)
  
  The cost (E\_mean) is decreasing but the accuracy on training data isn't. What happened too was that the accuracy has sky-rocketed but then dropped immediately.
  
  I'd be grateful for any help!
  
  **Tags:** neural-networks, accuracy
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2023-09-05. Score: 0
  
  If the **accuracy is sky-rocketing** unexpectedly during training (and then dropping immediately), my first hunch would be to experiment with the learning rate - **it seems that the learning rate may be too high**. Please remember that the learning rate is just a parameter that magnifies your step in the direction of the gradient calculated at point (t). It means that in (the case of first-order optimization) there is nothing that prohibits it from overshooting the local or global minimum.
  
  The second thing that I would like to inspect is the **architecture of the network**. Given that you have 100 inputs and then only 10 neurons, it is very likely that the architecture is just too simple to approximate the target function. However, this seems strange, as you are trying to approximate the sine, linear and quadratic functions. This should be feasible by using a rather simple architecture. I omit here a detailed explanation of the approximation of common functions. If you are interested, jump straight into an approximation of common polynomials and the minimum number of parameters required to do so.
  
  Finally, I wonder about your samples. You say that you generate some common functions and then sample points that serve as training data. Please keep in mind, that your sample should be reflective of the data-generating function. If it not (e.g. you sample only around some small interval) - you will not approximate the function correctly, even if your acc is 100% ;)
  
  
  ---
  
  ### Answer by username_2 on 2024-06-01. Score: 0
  
  Your network is always guessing the same output. I would recommend using cross-entropy loss rather than mean-squared error.
  
  
  ---
  
  ### Answer by username_3 on 2023-04-08. Score: 0
  
  One cause I can think of is that your network is too simple for the task. That would explain why the cost stops decreasing at around 0.33. Your network might be outputting the same prediction independent of the input, by using the bias values and setting the weights to low values. That would also be the reason why the accuracy is 0.33, because one third of the time the network is lucky and its guess matches the input.
  
  Another problem could be your that you are using a bad model architecture, for example using the wrong activation function. I suggest using the relu or the sigmoid function.
  
  I hope you are able to solve your problem.
  
  
  ---
  
  