pretrained deep learning network

4 views (last 30 days)
Ahmad Alhashil
Ahmad Alhashil on 22 Feb 2021
Answered: Aniket on 23 Sep 2024
hi!
iwhen i use the pre trained deep kearning network and use it with droesy detection, can i train it more and more to get higher accuarcy or i can not train it ?

Answers (1)

Aniket
Aniket on 23 Sep 2024
You can further train the pre-trained deep learning network and use it with drowsiness detection to get higher accuracy if you have a training dataset for the same. This process is called Transfer learning and MATLAB has extensive resources to carry out this task.
First of all, create an image datastore (imds). An image datastore enables you to store large collections of image data, including data that does not fit in memory, and efficiently read batches of images during training of a neural network. Partition the data into training, validation, and testing data sets. Use 70% of the images for training, 15% for validation, and 15% for testing. The splitEachLabel function splits the image datastore into three new datastores.
[imdsTrain,imdsValidation,imdsTest] = splitEachLabel(imds,0.7,0.15,0.15,"randomized");
Then follow these steps to train the network:
1. Load Pretrained Network
Open the pretrained model using MATLAB Deep Network Designer app.
2. Edit Network for Transfer Learning
In Designer pane, unlock a convolution layer/ fully connected layer and update the properties as per your required model and adjust the learning parameters. Export to save the modified network as net_1.
3. Specify Training Options
Define the training options using the trainingOptions function:
options = trainingOptions("adam", ...
ValidationData=imdsValidation, ...
ValidationFrequency=5, ...
Plots="training-progress", ...
Metrics="accuracy", ...
Verbose=false);
4. Train Neural Network
Train the network using the trainnet function with cross-entropy loss:
net = trainnet(imdsTrain, net_1, "crossentropy", options);
5. Test Neural Network
Classify the test images using minibatchpredict and convert scores to labels with scores2label:
inputSize = net.Layers(1).InputSize(1:2);
augimdsTrain = augmentedImageDatastore(inputSize, imdsTest);
YTest = minibatchpredict(net, imdsTest);
YTest = scores2label(YTest, classNames);
For detailed steps, follow the procedure mentioned in the following documentation:
I hope this helps you to train your model with higher accuracy!

Categories

Find more on Get Started with Deep Learning Toolbox in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!