www.gusucode.com > nnet 案例源码 matlab代码程序 > nnet/PredictContinuousMeasurementsExample.m

    %% Predict Continuous Measurements Using Trained Autoencoder

%% 
% Load the training data. 
X = iris_dataset; 

%%
% The training data contains measurements on four attributes of iris flowers:
% Sepal length, sepal width, petal length, petal width.  

%% 
% Train an autoencoder on the training data using the positive saturating
% linear transfer function in the encoder and linear transfer function in
% the decoder. 
autoenc = trainAutoencoder(X,'EncoderTransferFunction',...
'satlin','DecoderTransferFunction','purelin');  

%% 
% Reconstruct the measurements using the trained network, |autoenc|. 
xReconstructed = predict(autoenc,X);  

%% 
% Plot the predicted measurement values along with the actual values in
% the training dataset.
for i = 1:4
h(i) = subplot(1,4,i);
plot(X(i,:),'r.');
hold on 
plot(xReconstructed(i,:),'go');
hold off;
end
title(h(1),{'Sepal';'Length'});
title(h(2),{'Sepal';'Width'});
title(h(3),{'Petal';'Length'});
title(h(4),{'Petal';'Width'});

%%
% The red dots represent the training data and the green circles represent
% the reconstructed data.