Hi,
I am trying to train a network on a dataset. I would like to predict the coefficients of a spline that represent a contact force between to impacting objects and the total contact time. The spline coefficient vector has variable length depending on the case but as of now I get predictions of the same length ( set to the maximum lenght of the coefficients vector). This is the code I've written
inputTable = table;
predictorNames = {'v_i', 'E_tip', 'rho_tip', 'v_tip', 'Y_tip', ...
'Radius', 'E_plate', 'rho_plate', 'v_plate', 'Y_plate', 'Insulator'};
predictors = inputTable{:, predictorNames}';
maxLen = max(cellfun(@numel, inputTable.Sp));
responseCoeffs = zeros(maxLen, length(inputTable.Sp));
scalarResponse = inputTable.ContactTime;
for i = 1:length(inputTable.Sp)
coeffs = inputTable.Sp{i};
responseCoeffs(1:numel(coeffs), i) = coeffs;
end
predictors = normalize(predictors, 2);
responseCoeffs = normalize(responseCoeffs, 2);
scalarResponse = normalize(scalarResponse);
numFeatures = size(predictors, 1);
numSplineCoeffs = maxLen;
% LSTM
layers = [
sequenceInputLayer(numFeatures)
lstmLayer(50, 'OutputMode', 'sequence')
fullyConnectedLayer(100)
reluLayer
fullyConnectedLayer(numSplineCoeffs + 1)
regressionLayer
];
options = trainingOptions('adam', ...
'MaxEpochs', 1000, ...
'MiniBatchSize', 32, ...
'Shuffle', 'every-epoch', ...
'Plots', 'training-progress', ...
'Verbose', true);
fullResponse = [responseCoeffs; scalarResponse'];
net = trainNetwork(predictors, fullResponse, layers, options);
This is my first time trying to train a network so any advice even on where to find more information on how to select the corret type of network would be much appreciated.
Thanks in advance!

 채택된 답변

praguna manvi
praguna manvi 2025년 3월 12일

0 개 추천

Choosing the right architecture depends on the complexity of the problem. Here are some resources that discuss which approach to take based on the type of problem:
Since you have only 1800 samples, it would be easier to fit them with a lighter network, as more parameters require more data. Also, since R2023b, it is recommended to use "trainnet" instead. Refer to the following link for more examples:

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기

제품

릴리스

R2024b

질문:

2025년 3월 9일

답변:

2025년 3월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by