File Exchange

image thumbnail

Code Examples from Deep Learning Ebook

version (1.34 MB) by Johanna Pingel
Follow along with the code examples from the "Practical Deep Learning Examples with MATLAB" ebook


Updated 09 May 2018

View License

Learn three approaches to training a deep learning neural network:
1. training from scratch
2. transfer learning
3. semantic segmentation
This submission, along with the corresponding ebook, offers a hands-on approach to deep learning.

Cite As

Johanna Pingel (2020). Code Examples from Deep Learning Ebook (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (15)

qiu tao

just ctrl+f found Johanna's comment


Great one to start with on it..

Adam Lysiak

Got it, I downloaded individual files before. Thanks a lot!

@Adam - the MNISTModel is a .mat file included in the download of the files. It should be under Demo1_MNIST/MNISTModel.mat

Adam Lysiak

Hey, where can I find MNISTModel file (line 22)?

@Venkat - you can remove those lines of code, and the function should run properly without them. This was an old artifact that can be removed. Let me know if you have any trouble.

@Fajar: You are going to run into errors using this code in 2014a. The error is most likely because the function webread() was not introduced until 2014b. You can download the files manually using the link rather than using webread, but you will run into other challenges with the version 2014a, since our deep learning support came out in R2017a

Thank you for sharing the code for these examples. In the function prepareData.m, a couple of lines have been commented out. These are:
% img = readMNISTImage(imgDataTrain, 3);
% figure, imshow(img);

I wasn't able to locate the function readMNISTImage readily. Am I missing anything obvious? Very grateful if you could pint me in the right direction.
Venkat. v.v.s.s.sastry[AT]

i have this error.

>> MNIST_Classification_Demo
Preparing MNIST data...
Error using fread
Invalid file identifier. Use fopen to generate a valid file identifier.

Error in prepareData (line 42)
magicNum = fread(fid, 1, 'uint32');

Error in MNIST_Classification_Demo (line 11)
[imgDataTrain, labelsTrain, imgDataTest, labelsTest] = prepareData;

i use R2014a


Updated Image and Copyright. No changes to code.

MATLAB Release Compatibility
Created with R2018a
Compatible with any release
Platform Compatibility
Windows macOS Linux