Deep Learning Predict block does not reproduce trained network correctly

2 views (last 30 days)
The Predict Block contains the trained network. The trained network was trained on a fully convolutional (fc) neural net with 3 fc layers and 3 tanh activation. It contains 4 inputs (1 waveform, 2 constants and time) and should predict 4 outputs. The network was trained following the 'CB' format given that the input layer is convolutional.
Currently, the trained network reproduces the outputs correctly in Matlab but when called in Simulink, it reproduces incorrect output. How may I fix this issue? note that the network is a PINN.

Answers (1)

Parag
Parag on 5 Mar 2025
Hi, the issue may be due to the differences in data formatting, numerical precision, or simulation settings between MATLAB and Simulink. Since the trained PINN network follows the 'CB' format and works correctly in MATLAB, ensure that the input dimensions, data types, and preprocessing in Simulink match the training conditions.
Alsp verify that the inputs (waveform, constants, and time) are structured correctly and maintain the same normalization. Additionally, check Simulink solver settings, as differences in discretization or step size may affect results. Logging intermediate outputs and comparing them with MATLAB can help pinpoint discrepancies.
  2 Comments
Justus Nwoke
Justus Nwoke on 5 Mar 2025
Thanks for the response, We figured out the problem. The signal editor block when replaced with a 'from workspace' block solves the problem.
Now, I am eager to know why that is the case since the signal editor block is a more comprehensive block than the 'from workspace' block.
Parag
Parag on 6 Mar 2025
Edited: Parag on 6 Mar 2025
Great to hear that the issue was resolved! The difference in behavior between the Signal Editor block and the From Workspace block likely comes from how they handle time and interpolation in Simulink.
As per my understanding some possible Reasons why ‘From Workspace’ Works but ‘Signal Editor’ Doesn’t:
1.Interpolation and Time Handling:
  • The Signal Editor block generates signals based on internal interpolation, which may introduce discrepancies if the data points do not align exactly with the simulation time steps.
  • The From Workspace block directly imports discrete-time signals from MATLAB, ensuring that the data points match exactly with the ones used in training.
2. Sampling and Discretization:
  • The Signal Editor block allows for different time step configurations, which might not be fully compatible with how the trained PINN expects input data.
  • The From Workspace block adheres strictly to the sampling rate provided in the workspace variable, preventing unexpected modifications3
3. Data Structuring:
  • The Signal Editor might format multidimensional signals differently compared to how the From Workspace block does. This could affect the way the trained PINN interprets inputs.
4.Numerical Precision Differences:
  • If the Signal Editor applies internal processing (such as rounding, filtering, or resampling), this could slightly alter the input signal, leading to incorrect network predictions.
please refer to these documentations for more detail
From Workspace
Signal Editor

Sign in to comment.

Categories

Find more on Deep Learning with Simulink in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!