- Load the pre-trained CNN using MATLAB's alexnet (https://www.mathworks.com/help/deeplearning/ref/alexnet.html) or vgg16 (https://www.mathworks.com/help/deeplearning/ref/vgg16.html) functions, which will give you access to the CNN's layers and weights.
- Extract the activations of the CNN's final layer for your training data. These activations represent the "features" learned by the CNN that are most relevant to your problem.
- Use the extracted activations as input to your BPNN, along with any additional input features that may be relevant to your problem.
- Train the BPNN using the extracted activations as input and the desired outputs as targets.
I want to add CNN layer into a BPNN-PSO model, how can I do it?
33 次查看(过去 30 天)
显示 更早的评论
This code is writeen from scrach with a classical three layer BPNN (input-hideen-output)
I want to add a CNN layer between the hidden layer and output layer. And the whole code should can be optimized by the SPO or other optimizer. could anyone show me some hints? or how to rewrite this code?
Here is the original code in github
https://github.com/meton-robean/SPO_BPNN_PID/
0 个评论
回答(1 个)
Jasvin
2023-3-9
It is not possible to directly add a Convolutional Neural Network (CNN) layer to a Backpropagation Neural Network (BPNN) in MATLAB, as the two types of networks have different architectures and training algorithms.
However, you can use a technique called transfer learning to adapt a pre-trained CNN for use in a BPNN. Transfer learning involves taking a CNN that has already been trained on a large dataset, and using the features learned by the CNN to train a new network on a smaller, related dataset.
Here's a high-level overview of the process:
Note that this is just a general outline of the process, and the specific details will depend on the specific problem you are trying to solve. Additionally, there are many variations and optimizations to transfer learning that you may want to consider, such as fine-tuning the pre-trained CNN on your specific dataset, or using multiple pre-trained CNNs to extract features at different levels of abstraction.
MATLAB provides several functions that can help with transfer learning, including activations (https://www.mathworks.com/help/deeplearning/ref/seriesnetwork.activations.html), classify (https://www.mathworks.com/help/stats/classify.html) and trainNetwork (https://www.mathworks.com/help/deeplearning/ref/trainnetwork.html).
2 个评论
Jasvin
2023-3-13
If you want to use CNN layers, then you can fully convert to a CNN based network as well and you can use the following FileExchange submission as a starting point,
Also if you found my answer to be helpful then you can mark it as the accepted answer.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!