How to input a signal in frequency domain into an LSTM sequence to label network and use in Simulink model for fault detection?
Show older comments
I am training an LSTM network using trainNetwork function as sequence to label to detect faults in a dc circuit in my Simulink model. I have 11 measurements (currents and voltages etc.) in time domain which I use as features for the network; and 5 different fault types. For each fault case I run multiple simulations for different load, different dc voltages etc. Data is collected from the simulations and the network is trained on MATLAB (and later deployed to use in the Simulink model). My training data is in cell format as:
X_Train = Y_Train =
40×1 cell array 40×1 categorical array
{11×1919 double} 1
{11×1919 double} 0
{11×1919 double} 1
. .
. .
As seen, I have 11 features, data from 40 simulations (each is for different power, voltage ratings etc.), and 5 health conditions (0-healthy, 1-fault-type...4-fault-type). Here is the code for the network training:
inputSize = 11;
numHiddenUnits = 500;
numClasses = 5;
layers = [ ...
sequenceInputLayer(inputSize, 'Name', 'timeseq')
lstmLayer(numHiddenUnits,'OutputMode','last')
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer];
maxEpochs = 300;
miniBatchSize = 54;
options = trainingOptions('adam', ...
'ExecutionEnvironment','auto', ...
'MaxEpochs',maxEpochs, ...
'MiniBatchSize',miniBatchSize, ...
'GradientThreshold',1, ...
'Verbose',false, ...
'Plots','training-progress');
net = trainNetwork(X_Train,Y_Train,layers,options);
So far all good and the network detects 4 of the health conditions with 100% accuracy. However, the features are not good indicators for the network to detect one of the faults. So I use power spectral density from one of the voltage measurements and add it as another feature (12th feature). I adjust the length of the spectral function accordingly so that I get the same length as the other features (1919 in this case). Otherwise, trainNetwork does not like it and give error. So X_Train's cells are now {12×1919 double}. Note that by doing so the frequency domain power spectral density data is also treated as time sequenced feature when training the network. After training the network, the 5th fault is also detected when I use my test data in MATLAB. Then I import the network into predict block in Simulink. I input 11 measurements and 1 periodogram generated from one of the measurements into the network. However, of course, I get an error because the periodogram generates (nfft x 1) data per sample time not a single value per sample.
Is there any way to go around this problem in the training stage (training the network for that type of input so that I can input (nfft x 1) data as the 12th input of the predict block) or on Simulink side (somehow making the data type competable with the network input)? Any other methods for network training or implementing this is welcomed.
Accepted Answer
More Answers (0)
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!