- Extract training and validation accuracy from the trainnet output.
- Extract training and validation loss.
- Plot accuracy and loss over epochs.
how to plot performance graph for nueral network
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I wanted to plot an performace graph for the following example openExample('nnet/TrainABasicConvolutionalNeuralNetworkForClassificationExample')
please help
0 Kommentare
Antworten (1)
Parag
am 6 Mär. 2025
Hi, I see you want to plot a performance graph for your convolutional neural network (CNN) training process. MATLAB provides built-in functionality to visualize training performance using the “training-progress” plot in “trainingOptions”. However, if you want a custom plot, you can extract training and validation accuracy/loss from the training information and plot them separately.
Steps to Plot Performance Graph
MATLAB Code for Performance Graph
% Train the network and store training information
[net, trainInfo] = trainnet(imdsTrain, layers, "crossentropy", options);
% Extract accuracy and loss
trainAccuracy = trainInfo.Metrics.TrainingAccuracy;
valAccuracy = trainInfo.Metrics.ValidationAccuracy;
trainLoss = trainInfo.Metrics.TrainingLoss;
valLoss = trainInfo.Metrics.ValidationLoss;
epochs = 1:length(trainAccuracy); % Epoch numbers
% Plot Training and Validation Accuracy
figure;
subplot(2,1,1);
plot(epochs, trainAccuracy, '-o', 'LineWidth', 2);
hold on;
plot(epochs, valAccuracy, '-s', 'LineWidth', 2);
title('Training and Validation Accuracy');
xlabel('Epoch');
ylabel('Accuracy');
legend('Training Accuracy', 'Validation Accuracy');
grid on;
% Plot Training and Validation Loss
subplot(2,1,2);
plot(epochs, trainLoss, '-o', 'LineWidth', 2);
hold on;
plot(epochs, valLoss, '-s', 'LineWidth', 2);
title('Training and Validation Loss');
xlabel('Epoch');
ylabel('Loss');
legend('Training Loss', 'Validation Loss');
grid on;
0 Kommentare
Siehe auch
Kategorien
Mehr zu Directed Graphs finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!