Hello everyone. I try to run deep neural network for digit classification and i got this error;Undefined function or variable 'trainAutoencoder'. Where we can get the trainAutoencoder function?here is the code.
4 次查看(过去 30 天)
显示 更早的评论
% Load the training data into memory [xTrainImages, tTrain] = digittrain_dataset;
% Display some of the training images clf for i = 1:20 subplot(4,5,i); imshow(xTrainImages{i}); end
rng('default') hiddenSize1 = 100;
autoenc1 = trainAutoencoder(xTrainImages,hiddenSize1, ... 'MaxEpochs',400, ... 'L2WeightRegularization',0.004, ... 'SparsityRegularization',4, ... 'SparsityProportion',0.15, ... 'ScaleData', false);
view(autoenc1)
plotWeights(autoenc1);
feat1 = encode(autoenc1,xTrainImages);
hiddenSize2 = 50; autoenc2 = trainAutoencoder(feat1,hiddenSize2, ... 'MaxEpochs',100, ... 'L2WeightRegularization',0.002, ... 'SparsityRegularization',4, ... 'SparsityProportion',0.1, ... 'ScaleData', false);
view(autoenc2)
feat2 = encode(autoenc2,feat1);
softnet = trainSoftmaxLayer(feat2,tTrain,'MaxEpochs',400);
view(softnet)
view(autoenc1) view(autoenc2) view(softnet)
deepnet = stack(autoenc1,autoenc2,softnet);
view(deepnet)
% Get the number of pixels in each image imageWidth = 28; imageHeight = 28; inputSize = imageWidth*imageHeight;
% Load the test images [xTestImages, tTest] = digittest_dataset;
% Turn the test images into vectors and put them in a matrix xTest = zeros(inputSize,numel(xTestImages)); for i = 1:numel(xTestImages) xTest(:,i) = xTestImages{i}(:); end
y = deepnet(xTest); plotconfusion(tTest,y);
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Pattern Recognition and Classification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!