NSS block in Simulink with Swish Activation Fcn
51 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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 个)
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:
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!