Load and Retrain a Pretrained NN with a MATLAB GUI

Aus HSHL Mechatronik
Zur Navigation springen Zur Suche springen

Discrete Values vs. GUI

This task was about loading the pretrained NN with MATLAB® App (GUI) by clicking the desired path in the images. This method is the same method used in JupyterLab, but alternatively, since I already have steering angles with their corresponding frames, we can train a model to predict a steering angle based on new frames.

Pretrained Neural Network

A pretrained neural network is a model that’s already been trained on a large dataset for a general task (e.g., image classification on ImageNet). You can fine-tune it on your smaller, task-specific dataset—leveraging learned features to save time and improve performance.

Types of Pretrained NN

Tabelle 12: MATLAB Pretrained NN
Name Examples Description
Image Classification
  • AlexNet
  • VGG-16/VGG-19
  • ResNet-50/101
  • SqueezeNet
  • GoogLeNet
  • MobileNet-v2
  • EfficientNet-b0
Pretrained NN for image classification tasks.
Object Detection
  • YOLO v2
  • SSD (Single Shot Multibox Detector) a
  • Faster R-CNN
Pretrained models for detecting and localizing objects.
Semantic Segmentation
  • FCN-8s
  • U-Net
  • SegNet
  • DeepLab-v3+
Pretrained NN to label each pixel in an image.
Super-Resolution
  • SRCNN
  • ESPCN
  • EDSR pretrained models
Pretrained NN for upscaling low-resolution images.
Image Denoising
  • DnCNN
Pretrained NN for removing noise from images.
Image-to-Image Translation
  • pix2pix
  • CycleGAN
Pretrained NN for tasks like style transfer and domain adaptation.
Instance Segmentation
  • MATLAB provides Mask R-CNN (e.g., ResNet-50-FPN backbone) pretrained on COCO Annotator
NN for detecting and segmenting individual object instances.

All the above models can be downloaded from here [1].

How to Load, Retrain, and Fine-Tune a Pretrained NN

MATLAB has an integrated toolbox to run and test deep learning. ResNet18 is a pre-trained network we will be using to train our AI and then fine tune it.

  1. Load: Loading a pretrained neural network means importing its saved architecture and learned weights into MATLAB’s workspace. This gives you a ready-to-use model without training from scratch [[2]][[3]].
  2. Retrain: Retraining involves further training the entire loaded network on your own dataset. All layers’ weights are updated, often starting from the pretrained values [[4]][[5]].
  3. Finetune: Fine-tuning freezes most of the network’s layers and only updates a subset (typically higher-level layers) on new data. You use a lower learning rate so the pretrained features aren’t drastically altered [[6]][[7]].
Tabelle 13: MATLAB Pretrained NN
Name Application Description
Load
Fig. 23: Load NN
Loading a fine-tuned pre-trained NN or starting with a new pre-trained NN (ResNet-18).
Retrain
Fig. 24: Retrain an NN
Inside the while hasFrame(v) loop, every time frameBatch reaches MiniBatchSize, trainedNet is called.
Fine-tune
Fig. 25: Fine-tune
The pre-trained ResNet-18 is fine-tuned by using a low InitialLearnRate (1e-4) in trainingOptions and training on your new steering batches.