How to specify the loss parameters, learning rate, weight initilization and weight decay for unsupervised learning?

Roqyah_bdeen: <p>For a specific neural network that is designed for supervised learning stereo matching (stereo matching or disparity estimation is the process of finding the pixels in the multiscopic views that correspond to the same 3D point in the scene**), I am trying to change the supervised losses to unsupervised losses using the same network architecture. These unsupervised losses have been used before for the same task but with different network architectures. For the first training trail, my code gives Nan values after a few epochs. “I used torch.autograd.set_detect_anomaly(True)”<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/4/d/4dbff83c16ed89ccc30b1d008653956b423864ba.png" data-download-href="https://discuss.pytorch.org/uploads/default/4dbff83c16ed89ccc30b1d008653956b423864ba" title="disp-error"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/4/d/4dbff83c16ed89ccc30b1d008653956b423864ba_2_690x200.png" alt="disp-error" data-base62-sha1="b5O3CfPajRZLfZBIVqQyhUPGLIS" width="690" height="200" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/4/d/4dbff83c16ed89ccc30b1d008653956b423864ba_2_690x200.png, https://discuss.pytorch.org/uploads/default/optimized/3X/4/d/4dbff83c16ed89ccc30b1d008653956b423864ba_2_1035x300.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/4/d/4dbff83c16ed89ccc30b1d008653956b423864ba.png 2x" data-dominant-color="3F1D34"><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">disp-error</span><span class="informations">1126×328 386 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>could anyone guide me how to choose the appropriate loss parameters or learning rates, I reduced the learning rate from 0.0001 to 0.00001 which allows for more training epochs but it also gives nan value. could anyone explain the relationship between loss parameters, learning rate and Nan value in loss and if small numbers or large numbers are better and why, thank you so much in advance</p>

AbdulsalamBande: <p>When you encounter NaN values during training, it’s usually a sign that something is going wrong in the optimization process. NaN values can be a result of exploding gradients, vanishing gradients, or instability in the loss function itself. Here are some tips</p>
<ol>
<li>Set appropriate loss parameters to ensure stability and convergence during training.</li>
<li>Choose a suitable learning rate to avoid overshooting or slow convergence; consider using learning rate schedulers.</li>
<li>Apply gradient clipping to limit gradient magnitudes and prevent exploding gradients.</li>
<li>Use batch normalization layers to improve training stability.</li>
<li>Ensure unsupervised loss functions are numerically stable to avoid NaN or infinity values.</li>
<li>Initialize weights properly using techniques like Xavier or He initialization.</li>
</ol>

Roqyah_bdeen: <p>Thank you so much<br>
it was an exploding gradient and I have used gradient cropping to solve it.<br>
but I just still have one problem, the loss reached a specific loss value, which is still high, and stops decreasing, The original baseline can achieve much lower loss, the current network architecture is much better but with the unsupervised losses it doesn’t give a good results.<br>
Is there any point that could help me solve that</p>
<p>thank you so much in advance</p>