which is the best network to predict vibration response( output) against time varying force (input) ?
조회 수: 3 (최근 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);
댓글 수: 0
채택된 답변
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!
추가 답변 (0개)
참고 항목
카테고리
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!