which is the best network to predict vibration response( output) against time varying force (input) ?

2 ビュー (過去 30 日間)
will this kind of network work for it. in the attachement coulumn 2 is f(t) input and column 3 is x(t) i.e output? can anyone cross check what i have to modify to get the results correctly.
% Load and preprocess data
inputData = Predictors_train; % Time series force input data (100 values)
outputData = Responsers_train; % Corresponding time series displacement data (100 values)
% Split data into training and validation sets
cvp = 0.6; % 60% for training
idxTrain = 1:round(cvp*length(inputData));
idxVal = (round(cvp*length(inputData))+1):length(inputData);
XTrain = inputData(idxTrain, :);
YTrain = outputData(idxTrain, :);
XVal = inputData(idxVal, :);
YVal = outputData(idxVal, :);
% Define the number of features and responses
numFeatures = size(XTrain, 2); % Number of features in input data
numResponses = size(YTrain, 2); % Number of responses
% Define LSTM network architecture
layers = [ ...
sequenceInputLayer(numFeatures)
lstmLayer(12, 'OutputMode', 'sequence')
dropoutLayer(0.2)
% lstmLayer(32, 'OutputMode', 'sequence') % 'sequence' for sequence-to-sequence
% dropoutLayer(0.2)
fullyConnectedLayer(numResponses)
regressionLayer];
% Specify training options
maxEpochs = 10;
miniBatchSize = 16;
options = trainingOptions('adam', ...
'MaxEpochs', maxEpochs, ...
'MiniBatchSize', miniBatchSize, ...
'Shuffle', 'every-epoch', ...
'Plots', 'training-progress', ...
'Verbose', false);
% Convert training data to cell arrays
XTrain = num2cell(XTrain, 2); % Convert each sequence to a separate cell
YTrain = num2cell(YTrain, 2); % Convert each sequence to a separate cell
% Train LSTM network
net = trainNetwork(XTrain, YTrain, layers, options);
% Validate trained network
YPredVal = predict(net, num2cell(XVal, 2)); % Convert XVal to cell array
valRMSE = sqrt(mean((YVal - cell2mat(YPredVal)).^2)); % Convert YPredVal back to matrix
disp(['Validation RMSE: ', num2str(valRMSE)]);
figure;
plot(cell2mat(YPredVal));
new_input_data = Predictors_test;
% Make predictions on new data
XNew = num2cell(new_input_data, 2); % Convert new input data to cell array
YPred = predict(net, XNew); % Predict using the trained network
Ypred_mat=cell2mat(YPred);
Y_actual = Responsers_test;
figure;
plot(time_series,Ypred_mat,'r','LineWidth',1.2);
hold on;
plot( time_series, Y_actual, 'b','LineWidth',1);

採用された回答

Shivansh
Shivansh 2024 年 5 月 26 日
Hi Thushar!
It looks like you have set up an LSTM network for predicting vibration response to time-varying forces.
The LSTM networks are indeed a good option for your problem due to their ability to capture temporal dependencies.
You can follow some common practices to find the issue with your current model and getting better results from them.
You can try to normalize your data for consistent scale, experiment with model complexity (adding or removing layers and neurons), adjust hyperparameters like epochs and batch size for better training, or use cross-validation for robust evaluation.
You can also explore different metrics such as MAE or MAPE for a comprehensive performance assessment.
The comparison of LSTM with other sequence models like GRUs or Transformers could also reveal a more effective solution for your specific problem.
You can refer to the following link to learn more about LSTMs in MATLAB: https://www.mathworks.com/discovery/lstm.html.
I hope it helps!
  2 件のコメント
Thushar
Thushar 2024 年 5 月 27 日
the link is not working though
Shivansh
Shivansh 2024 年 5 月 27 日
I don't know the issue with the previous link.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by