I cannot find the helper functions "processImagesMNIST" and "processLabelsMNIST"
Mostra commenti meno recenti
In the documentation linked below ("Train Variational Autoencoder (VAE) to Generate Images") the two helper functions, mentioned in the title of this question, are said to be attached in the example and they are supposed to read the MNIST files and store them in MATLAB arrays.
However, I cannot find these helper functions and I have searched everywhere without result. I used some other loading functions instead but then I encounter problems when trying to implement the images correctly, probably because of dimension problems in the input data.
Thankful if somebody can help me find the functions or similar ones which can work in the example code in the link below.
Risposte (2)
James Latshaw
il 25 Mar 2022
Matlab does a terrible job keeping up with the MNIS support as they upate versions.
But you can make a new function like the one below that will work for you :)
function X = processLabelsMNIST(filename)
dataFolder = fullfile(tempdir,'mnist');
gunzip(filename,dataFolder)
[~,name,~] = fileparts(filename);
[fileID,errmsg] = fopen(fullfile(dataFolder,name),'r','b');
if fileID < 0
error(errmsg);
end
magicNum = fread(fileID,1,'int32',0,'b');
if magicNum == 2049
fprintf('\nRead MNIST label data...\n')
end
numImages = fread(fileID,1,'int32',0,'b');
fprintf('Number of labels in the dataset: %6d ...\n',numImages);
X = fread(fileID,inf,'unsigned char');
X = reshape(X,[1,size(X,1)]);
%X = reshape(X,numCols,numRows,numImages);
%X = permute(X,[2 1 3]);
%X = X./255;
%X = reshape(X, [28,28,1,size(X,3)]);
fclose(fileID);
end
2 Commenti
debojit sharma
il 15 Giu 2023
If I have stored my image dataset in a folder( that contains subfolders of 4 classes of images) then how can I prepare my dataset as per the function processLabelsMNIST
debojit sharma
il 15 Giu 2023
If I have stored my image dataset in a folder( that contains subfolders of 4 classes of images) then how can I prepare my dataset as per the function processLabelsMNIST. That is after loading the images using the imagedatastore function how to convret the training images in a format suitable for processLabelsMNIST
Srivardhan Gadila
il 7 Apr 2020
The Example you are referring to is w.r.t MATLAB R2020a. I have found that there have been some changes in the example.
Alternatively you can run the following command in the command window to open the example:
openExample('nnet/GeneratingHanddrawnDigitsUsingAVariationalAutoencoderVAEExample')
Based on your MATLAB version you can find the respective helper functions.
4 Commenti
Jörgen Ripa
il 2 Giu 2020
That answer did not help at all. I have the same problem. Please read the question.
Joergen
Steven Lord
il 2 Giu 2020
I opened the example in release R2020a by running the command shown by clicking the "View MATLAB Command" link on that example page in MATLAB.
openExample('nnet/GeneratingHanddrawnDigitsUsingAVariationalAutoencoderVAEExample')
I right-clicked on processImagesMNIST on line 5 of the example and chose 'Open "processImagesMNIST"' in the context menu that appeared. It opened this helper. I was able to do the same thing with processLabelsMNIST on line 8.
Jörgen Ripa, please try those steps:
- Run the openExample call.
- Right-click on the name of the helper function.
- Select the Open option in the context menu.
Does the helper function open for you when you run those steps? If not, if you receive an error during one of those steps, please show us the full and exact text of the error message (all the text displayed in red) that you receive and tell us at which step the error occurred.
AMIR KHAN
il 23 Mar 2021

AMIR KHAN
il 24 Mar 2021
I am getting the error as shown in the screenshot. Why it is showing the reshaping error.
Categorie
Scopri di più su Deep Learning Toolbox in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!