Hi,
One possible error could be due to taking a transposed vector in your code. Please check the code for ‘train’ for shallow training and using ‘trainNetwork’. It is working for me;
% Generate dummy data
numSamples = 500;
numFeatures = 5;
% Random input data
X = rand(numSamples, numFeatures);
% Random target values (for regression)
Y = rand(numSamples, 1);
% Create and configure a shallow neural network
shallowNet = feedforwardnet(10); % Example with 10 hidden neurons
% Train the shallow network
shallowNet = train(shallowNet, X', Y'); % Note the transpose to match input dimensions
% Define the layers for a deep learning model
layers = [
featureInputLayer(numFeatures) % 5 features
fullyConnectedLayer(10) % Example hidden layer
reluLayer % Activation layer
fullyConnectedLayer(1) % Output layer for regression
regressionLayer % Regression layer
];
% Set training options
options = trainingOptions('adam', ...
'MaxEpochs', 100, ...
'MiniBatchSize', 32, ...
'Plots', 'training-progress');
% Train the deep network
deepNet = trainNetwork(X, Y, layers, options);