I am trying to train a neural network using the "trainnet" function. My setup involves splitting a dataset into training and test sets, and then training a network with the following relevant code:
% Split data into training and test sets[idxTrain, idxTest] = trainingPartitions(size(myDataTable, 1), [0.85, 0.15]);trainData = myDataTable(idxTrain, :);
% Prepare training datapredictorNames = ["feature1", "feature2", "feature3", "feature4"];XTrain = table2array(trainData(:, predictorNames));TTrain = trainData.targetColumn;
% Define network layerslayers = [ featureInputLayer(numel(predictorNames), Normalization="zscore") fullyConnectedLayer(16) reluLayer fullyConnectedLayer(2) softmaxLayer];
% Train networkoptions = trainingOptions("lbfgs", ExecutionEnvironment="cpu", Plots="training-progress", Verbose=false);net = trainnet(XTrain, TTrain, layers, "crossentropy", options);
However, I encounter the following error:
Error using trainnet
Number of channels in predictions (2) must match the number of channels in the targets (1).
Why is this happpening?