フィルターのクリア

(deep learning)how to get probability output of softmax in this code?

8 ビュー (過去 30 日間)
Yeon Hwee Bae
Yeon Hwee Bae 2020 年 9 月 21 日
回答済み: Yeon Hwee Bae 2020 年 9 月 22 日
%%
[XTrain,YTrain] = japaneseVowelsTrainData;
XTrain(1:5)
%%
figure
plot(XTrain{1}')
xlabel("Time Step")
title("Training Observation 1")
numFeatures = size(XTrain{1},1);
legend("Feature " + string(1:numFeatures),'Location','northeastoutside')
%%
numObservations = numel(XTrain);
for i=1:numObservations
sequence = XTrain{i};
sequenceLengths(i) = size(sequence,2);
end
%%
[sequenceLengths,idx] = sort(sequenceLengths);
XTrain = XTrain(idx);
YTrain = YTrain(idx);
%%
figure
bar(sequenceLengths)
ylim([0 30])
xlabel("Sequence")
ylabel("Length")
title("Sorted Data")
%%
miniBatchSize = 27;
%%
inputSize = 12;
numHiddenUnits = 100;
numClasses = 9;
layers = [ ...
sequenceInputLayer(inputSize)
bilstmLayer(numHiddenUnits,'OutputMode','last')
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer]
%%
maxEpochs = 100;
miniBatchSize = 27;
options = trainingOptions('adam', ...
'ExecutionEnvironment','cpu', ...
'GradientThreshold',1, ...
'MaxEpochs',maxEpochs, ...
'MiniBatchSize',miniBatchSize, ...
'SequenceLength','longest', ...
'Shuffle','never', ...
'Verbose',0, ...
'Plots','training-progress');
%%
net = trainNetwork(XTrain,YTrain,layers,options);
%%
[XTest,YTest] = japaneseVowelsTestData;
XTest(1:3)
%%
numObservationsTest = numel(XTest);
for i=1:numObservationsTest
sequence = XTest{i};
sequenceLengthsTest(i) = size(sequence,2);
end
[sequenceLengthsTest,idx] = sort(sequenceLengthsTest);
XTest = XTest(idx);
YTest = YTest(idx);
%%
miniBatchSize = 27;
YPred = classify(net,XTest, ...
'MiniBatchSize',miniBatchSize, ...
'SequenceLength','longest');
%%
acc = sum(YPred == YTest)./numel(YTest)
this is mathworks example code for sequence classification.
'Ypred' shows me the predicted classes
but I want to know the result after softmax, before prediction, the probablity.
how to know?

採用された回答

Yeon Hwee Bae
Yeon Hwee Bae 2020 年 9 月 22 日
self answering : use predict(net, X)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSequence and Numeric Feature Data Workflows についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by