NSS block in Simulink with Swish Activation Fcn

36 ビュー (過去 30 日間)
Saskia Putri
Saskia Putri 2024 年 10 月 23 日
コメント済み: Saskia Putri 2024 年 10 月 30 日 12:29
Hi,
I have trained my neural state space with Swish activation function using MATLAB 2024b version. However I have not been able to test the accuracy using the Neural SS model in Simulink. I have multiple warnings and thereafter followed by error. If anyone can help, please kindly let me know. Thank you.
Warning: nnet.cnn.layer.SwishLayer is not supported. A placeholder subsystem will be added for 'act1'.
Warning: nnet.cnn.layer.SwishLayer is not supported. A placeholder subsystem will be added for 'act2'.
Warning: nnet.cnn.layer.SwishLayer is not supported. A placeholder subsystem will be added for 'act3'.
Warning: nnet.cnn.layer.SwishLayer is not supported. A placeholder subsystem will be added for 'act4'.
Warning: nnet.cnn.layer.SwishLayer is not supported. A placeholder subsystem will be added for 'act5'.
Warning: 'Input Port 1' of 'nlss_simulator/Neural State Space Model/NSS/State Network/State
Network/NetworkSubsystem/act4/out' is not connected.
Warning: 'Input Port 1' of 'nlss_simulator/Neural State Space Model/NSS/State Network/State
Network/NetworkSubsystem/act2/out' is not connected.
Warning: 'Input Port 1' of 'nlss_simulator/Neural State Space Model/NSS/State Network/State
Network/NetworkSubsystem/act1/out' is not connected.
Warning: 'Input Port 1' of 'nlss_simulator/Neural State Space Model/NSS/State Network/State
Network/NetworkSubsystem/act5/out' is not connected.
Warning: 'Input Port 1' of 'nlss_simulator/Neural State Space Model/NSS/State Network/State
Network/NetworkSubsystem/act3/out' is not connected.
Error using test (line 19)
Compilation of model 'nlss_simulator' failed while trying to resolve underspecified signal dimensions.
Caused by:
Error using test (line 19)
Matrix multiply dimensions propagation error. Error occurred while setting 'Input Port 2' of
'nlss_simulator/Neural State Space Model/NSS/State Network/State Network/NetworkSubsystem/dxdt/Matrix
Multiply' to have the dimensions [1 x 1]. A possible cause for this error is that these dimensions do not
agree with the partial dimensions information present on other ports
Error using test (line 19)
Error in port widths or dimensions. 'Output Port 1' of 'nlss_simulator/Neural State Space Model/NSS/State
Network/State Network/NetworkSubsystem/dxdt/Reshape' is a [1x1] matrix.

採用された回答

Tianyu
Tianyu 2024 年 10 月 28 日 13:44
Hi Saskia,
As warning suggests, swish is currently not supported in Simulink.
We have fully supported the activations in command line, but for Simulink, elu, swish, softplus and scaling are not yet added.
We should have mentioned this in doc. Sorry about the confusion.
For now, please use other activations if simulation is needed.
  1 件のコメント
Saskia Putri
Saskia Putri 2024 年 10 月 30 日 12:29
I understand. Thank you for the clarification.

サインインしてコメントする。

その他の回答 (1 件)

Subhajyoti
Subhajyoti 2024 年 10 月 27 日 11:08
It is my understanding that you are trying to test the Neural State-Space Model that you have trained. The error you are encountering, “Multiply' to have the dimensions [1 x 1]. A possible cause for this error is that these dimensions do not agree with the partial dimensions information present on other ports)” indicates a mismatch between the input and expected shapes in the model, which is generally sensitive to input dimensions and layer compatibility.
Here, in the following implementation, I have estimated and validated a neural state space model with “Swish” as activation functions, using dummy values.
rng(0)
Ts = 0.1;
sys = ss(c2d(tf(1,[1 1]),Ts));
sys.b = sys.b*sys.c;
sys.c = 1;
te = 0:Ts:10;
ue = randn(length(te),size(sys.B,2));
ye = lsim(sys,ue,te,zeros(size(sys.B,1),1));
tv = 0:Ts:1;
uv = randn(length(tv),size(sys.B,2));
yv = lsim(sys,uv,tv,zeros(size(sys.B,1),1));
% Create object for time series data
estimationData = iddata(ye,ue,0.01);
validationData = iddata(yv,uv,0.01);
% Construct neural state space object
nss = idNeuralStateSpace(1, NumInputs = 1, Ts = 0.01);
% Specify state network parameters
stateNetwork = createMLPNetwork(nss, 'state', Activations = 'swish', LayerSizes = 16);
nss.StateNetwork = stateNetwork;
% Specify training algorithm parameters
opt = nssTrainingOptions('adam');
opt.MiniBatchSize = 100;
% Estimate neural state space model
sys2 = nlssest(estimationData,nss,opt);
% Display results
compare(estimationData,sys2);
clear estimationData nss opt stateNetwork;
title('Fit to estimation data');
figure;
compare(validationData,sys2);
clear validationData;
title('Fit to validation data');
Additionally, you can refer to the following resources to know more ‘Neural State-Space Models’ in MATLAB:
  1 件のコメント
Saskia Putri
Saskia Putri 2024 年 10 月 30 日 12:29
This is very helpful. thank you.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSequence and Numeric Feature Data Workflows についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by