- 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
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I wanted to plot an performace graph for the following example openExample('nnet/TrainABasicConvolutionalNeuralNetworkForClassificationExample')
please help
0 Commenti
Risposte (1)
Parag
il 6 Mar 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 Commenti
Vedere anche
Categorie
Scopri di più su Directed Graphs in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!