which is the best network to predict vibration response( output) against time varying force (input) ?
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);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); 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); matlab, vibration dataset, neural network, lstm MATLAB Answers — New Questions