Need some advice on 1D CNN trained on synthetic spectra to predict the frequency of a single minimum on real signal

Marklee01: <p>Hi. I’m an undergraduate studying plasma, trying to apply deep learning to my research. I don’t have local ML support, so I had to study it all by myself and get some help from AI tools. I ’m seeking practical advice from PyTorch experts. I’ll not going to explain all the details about physics and focus on the ML/code side.</p>
<p>First of all, I’m not good at English so sorry if my sentences might sound awkward or rude. I got some help from AI tools either. I’m not sure if my topic’s format is appropriate, I’ll modify anytime if so.</p>
<p>I really want to appreciate first for spending your time.</p>
<p><strong>Problem</strong></p>
<ul>
<li>
<p>Input: a 1D spectrum (frequency vs. response) that typically has an <strong>N-shaped curve with a single clear minimum</strong>.</p>
</li>
<li>
<p>Goal: <strong>regress the frequency xxx</strong> at that minimum (scalar output).</p>
</li>
<li>
<p>Motivation: classic fitting or “find local minimum” rules can fail when the curve flattens under some conditions or is noisy.</p>
</li>
<li>
<p><strong>Approach (simulation → real)</strong></p>
<ul>
<li>
<p>I can generate <strong>synthetic spectra</strong> from a simple circuit model, then add perturbations (noise, drift, local bumps) to mimic measurement conditions.</p>
</li>
<li>
<p><strong>Model &amp; inputs:</strong> small <strong>1D CNN</strong> with <strong>3 input channels</strong>: <code>[frequency axis, S21 in dB, first derivative dS/df]</code>.</p>
<ul>
<li>Derivative is computed with <strong>Savitzky–Golay</strong> (fixed window/polyorder) after resampling onto a fixed training grid.</li>
</ul>
</li>
<li>
<p><strong>Training:</strong> synthetic data only (large set). Loss = <strong>SmoothL1</strong>, optimizer = <strong>Adam</strong>, scheduler = <strong>ReduceLROnPlateau</strong>.</p>
</li>
<li>
<p><strong>Inference:</strong> real <strong>signal</strong> traces are parsed, resampled to the same grid, derivative computed the same way, then passed to the model.</p>
</li>
</ul>
</li>
</ul>
<p>first and second Figures below are How the Actual experiment Data looks like and the Third one is how synthetic data looks like.</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/5/e/5ea9e88e17d4fd426c8cb07b0322d87cb6bf22a0.png" data-download-href="https://discuss.pytorch.org/uploads/default/5ea9e88e17d4fd426c8cb07b0322d87cb6bf22a0" title="Pytorch question"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/5/e/5ea9e88e17d4fd426c8cb07b0322d87cb6bf22a0_2_690x141.png" alt="Pytorch question" data-base62-sha1="dvqUnsCI5f2dkNiAqF0WISKoDDO" width="690" height="141" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/5/e/5ea9e88e17d4fd426c8cb07b0322d87cb6bf22a0_2_690x141.png, https://discuss.pytorch.org/uploads/default/optimized/3X/5/e/5ea9e88e17d4fd426c8cb07b0322d87cb6bf22a0_2_1035x211.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/5/e/5ea9e88e17d4fd426c8cb07b0322d87cb6bf22a0_2_1380x282.png 2x" data-dominant-color="F7F7F6"><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">Pytorch question</span><span class="informations">2008×412 98.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>
<ul>
<li></li>
</ul>
<p><strong>What I observe</strong></p>
<ul>
<li>
<p>On the synthetic validation set the model is reasonable, but on <strong>real data</strong> the prediction is <strong>consistently biased in one direction</strong> (systematic offset).</p>
</li>
<li>
<p>Preprocessing (grid + derivative method) is kept the same between train and inference.</p>
</li>
</ul>
<p><strong>What I’d like feedback on</strong></p>
<ol>
<li>
<p><strong>Sim-to-real feasibility:</strong> Is it realistic to train only on synthetic spectra and generalize to real traces? If so, what are the <em>key</em> practices (preprocessing, normalization, augmentations, loss/scheduler choices) that usually make this work?</p>
</li>
<li>
<p><strong>Non-DL or hybrid options:</strong> If deep learning isn’t strictly necessary, are there robust alternatives or hybrids you’ve found effective for predicting the minimum’s x-location when curves can be flat/noisy?</p>
</li>
<li>
<p><strong>Mixing real data:</strong> If I can label a <strong>small</strong> set of real traces, how would you mix them with synthetic data? (e.g., pretrain on synthetic → fine-tune only the head/BN on real; or a fixed ratio like 90:10 or 80:20?) Any rules of thumb?</p>
</li>
<li>
<p><strong>Model/code review:</strong> With inputs <code>[freq, S21, dS/df]</code> and a small 1D CNN (Conv-BN-ReLU-Pool blocks → GAP → FC), SmoothL1+Adam+Plateau scheduler:</p>
<ul>
<li>
<p>Any obvious <strong>anti-patterns</strong> or <strong>easy wins</strong> (e.g., channel normalization, scheduler choice like cosine restarts/one-cycle, initialization details for ReLU, loss reweighting near the minimum, handling boundary effects after resampling, etc.)?</p>
</li>
<li>
<p>Suggestions to <strong>reduce systematic bias</strong> on real data are especially welcome.</p>
</li>
</ul>
</li>
</ol>
<p><strong>Extra details (compact)</strong></p>
<ul>
<li>
<p><strong>Data:</strong> synthetic ~100k traces on a fixed grid; real .s2p have irregular grids → resampled to training grid.</p>
</li>
<li>
<p><strong>Augmentations:</strong> additive noise (pressure-dependent scale), slow drift, small local bumps; all applied <em>after</em> generating the clean model curve, then the derivative is computed.</p>
</li>
<li>
<p><strong>Environment:</strong> Colab, PyTorch.</p>
</li>
</ul>
<p>I can share my code if it’s needed. Thanks in advance for any pointers!</p>