Extracting feature vectors as input to train other network

1 view (last 30 days)
After Extracting feature vectors from pre-trained models, I would like to use those produced features to train a deep neural network with a number of fully connected layers. What can i do?
Thank you for your answer.

Answers (1)

Animesh Gupta
Animesh Gupta on 30 Aug 2022
Hello,
It is my understanding that you want to reuse the feature vector from pre-trained model and then append it with fully connected layers to train a custom deep learning model.
You may refer the following script that demonstrates a similar procedure.
In this demonstrattion, we are using pretrained GoolgeLeNet neural network and replacing fully connected layer and output layer.
net = googlenet; % loading pretrained GoogleLeNet neural network
lgraph = layerGraph(net); % extracting the layer graph of the model
newLearnableLayer = fullyConnectedLayer(5, ...
'Name','new_fc', ...
'WeightLearnRateFactor',10, ...
'BiasLearnRateFactor',10); % creating a new custom layer for our model
lgraph = replaceLayer(lgraph,'loss3-classifier',newLearnableLayer); % replace the existing 'loss3-classifier' with our newLearnableLayer
newClassLayer = classificationLayer('Name','new_classoutput'); % creating a new classification layer of name as new_classoutput
lgraph = replaceLayer(lgraph,'output',newClassLayer); % replacing output layer of original GoogleLeNet with our custom output layer
deepNetworkDesigner(lgraph) % visualizing the change
It can be observed that "loss3-classifier" and "output" layers are replaced with our new custom layers.
In a similar fashion, new layers can also be added in the network using addLayers and connectLayers method of layerGraoh object.
You can refer the following documentation for more information -
I hope it helps.

Categories

Find more on 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!