- Modify your network architecture to have two input channels: one for the 11 measurements and another for the PSD feature. This way, the network can learn to process the two types of inputs separately and capture the relevant information from each.
- Preprocess the PSD per timestep to extract relevant information that can be represented by a single value per sample. For example, statistical measures such as mean, maximum, or dominant frequency from the PSD and use them as the 12th feature. This way, you can reduce the PSD data to a single value per sample, which is compatible with the current network input.
- Extract specific features from the PSD that are more informative for fault detection. This can include frequency band power ratios, spectral moments, or other domain-specific features that capture the characteristics of the faults. By carefully selecting and engineering these features, you can reduce the PSD data to a single value per sample.
- Ensure that the PSD feature is properly normalized to have a similar scale as the other features. This normalization step is important to prevent any single feature from dominating the learning process.
How to input a signal in frequency domain into an LSTM sequence to label network and use in Simulink model for fault detection?
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mustafa Kaya
el 17 de Ag. de 2023
Comentada: Mustafa Kaya
el 26 de Oct. de 2023
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.
0 comentarios
Respuesta aceptada
VINAYAK LUHA
el 14 de Sept. de 2023
Hi Mustafa,
As per my understanding your X_train has the dimension 40x12x1919 (40 simulations, 12 features, 1919 samples), Among the features, there's one "spectral density" feature in frequency domain which as per your setting is considered as a time sequenced feature like the rest 11 features .
Regarding your X_test data, for the feature named "spectral density" you have 1x1x((nfft x1)x1919) data per simulation, which is inconsistent with the training data and causes error.
Power Spectral Density henceforth is referred to as PSD.
Here are possible workarounds to resolve the issue -
In the Simulink model, you can use a MATLAB Function block to preprocess the PSD in a similar manner as described above before passing it to the trained LSTM network. This MATLAB Function block can calculate the statistical measures or apply feature engineering techniques to extract the relevant information from the PSD and generate a single value per sample. The output of the MATLAB Function block can then be connected to the 12th input of the LSTM network.
Regards,
Vinayak Luha
Más respuestas (0)
Ver también
Categorías
Más información sobre Deep Learning with Simulink en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!