%% Reset Network State
% Reset the network state between sequence predictions.
% Load JapaneseVowelsNet, a pretrained long short-term memory (LSTM) network trained on the Japanese Vowels data set as described in [1] and [2]. This network was trained on the sequences sorted by sequence length with a mini-batch size of 27.

load JapaneseVowelsNet

% View the network architecture.

net.Layers

%
% Load the test data.

[XTest,YTest] = japaneseVowelsTestData;

% Classify a sequence and update the network state. For reproducibility, set rng to 'shuffle'.

rng('shuffle')
X = XTest{94};
[net,label] = classifyAndUpdateState(net,X);
label

% Classify another sequence using the updated network.

X = XTest{1};
label = classify(net,X)

% Compare the final prediction with the true label.

trueLabel = YTest(1)

% The updated state of the network may have negatively influenced the classification. Reset the network state and predict on the sequence again.

net = resetState(net);
label = classify(net,XTest{1})

% Copyright 2019 The MathWorks, Inc.