%% Predict Output Scores of Trained Network
% Load the pretrained GoogLeNet network. This step requires the Deep Learning Toolbox™ Model for GoogLeNet Network support package. If you do not have the required support packages installed, then the software provides a download link.

net = googlenet;

% View the network input size.

inputSize = net.Layers(1).InputSize

% Read an image using the imread function.

I = imread("peppers.png");
figure
imshow(I)

%
% Resize the image to the input size of the network using the imresize function.

I = imresize(I,inputSize(1:2));

% Predict the output scores using the predict function.

scores = predict(net,I);

% Visualize the top predictions in a bar chart. To remove the unused categories from the classes, use the removecats function.

classes = net.Layers(end).Classes;
[scoresTop,idx] = maxk(scores,5);

figure
bar(removecats(classes(idx)),scoresTop)
ylim([0 1])
title('Top 5 Predictions')
ylabel('Score')

% Copyright 2019 The MathWorks, Inc.