Loss error fluctuates greatly

zyz1996: <p>I am using lstm to predict the wave height, but the loss error fluctuates very much, what could be the reason?</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/9/f/9fac516e0295a24ed494197617df780a998d76b8.png" data-download-href="https://discuss.pytorch.org/uploads/default/9fac516e0295a24ed494197617df780a998d76b8" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/9/f/9fac516e0295a24ed494197617df780a998d76b8_2_690x366.png" alt="image" data-base62-sha1="mMx6FB203ni0aqvhZyU8OccHDny" width="690" height="366" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/9/f/9fac516e0295a24ed494197617df780a998d76b8_2_690x366.png, https://discuss.pytorch.org/uploads/default/optimized/3X/9/f/9fac516e0295a24ed494197617df780a998d76b8_2_1035x549.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/9/f/9fac516e0295a24ed494197617df780a998d76b8.png 2x" data-dominant-color="A9CAE1"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1228×652 26.7 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/1/6/162d3fab8d1623a71e3ea7f11b53d391c4ff2c12.png" data-download-href="https://discuss.pytorch.org/uploads/default/162d3fab8d1623a71e3ea7f11b53d391c4ff2c12" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/1/6/162d3fab8d1623a71e3ea7f11b53d391c4ff2c12.png" alt="image" data-base62-sha1="3abrQYTM4JcTLklY2WeEX0buk5c" width="690" height="391" data-dominant-color="303030"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">745×423 18.8 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/5/8/589a0564e4e6cd8129596b51b45b0a6cdd0cc984.png" data-download-href="https://discuss.pytorch.org/uploads/default/589a0564e4e6cd8129596b51b45b0a6cdd0cc984" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/5/8/589a0564e4e6cd8129596b51b45b0a6cdd0cc984.png" alt="image" data-base62-sha1="cDO0n99tXG57jMOGqOZmvZWTkOg" width="690" height="385" data-dominant-color="2E2E2F"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">838×468 12.9 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

ptrblck: <p>Are you using a synthetic dataset, which could have the same or a similar pattern?<br>
Did you check the model output and could you see if the model was just predicting a single class?</p>

zyz1996: <p>Do you mean there may be a problem with the data, I am using lstm to predict the wave height.</p>

ptrblck: <p>This is just a guess and your model might just output a straight line, while the data might have waves.<br>
This would create such a “wavy” loss curve, no?</p>

zyz1996: <p>You are right, the output is a straight line, how can I solve this problem</p>

ptrblck: <p>You could try to scale down the problem a bit, use a small data samples (e.g. only 10 samples), and try to overfit the model on this dataset by playing around with the hyperparameters, architecture, optimizer etc.</p>
<p>Once your model successfully predicts the small dataset, you could then try to scale it up again.</p>