I want to add CNN layer into a BPNN-PSO model, how can I do it?

7 Ansichten (letzte 30 Tage)
HONG CHENG am 2 Mär. 2023
Kommentiert: Jasvin am 13 Mär. 2023
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

Antworten (1)

Jasvin am 9 Mär. 2023
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:
  1. 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.
  2. 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.
  3. Use the extracted activations as input to your BPNN, along with any additional input features that may be relevant to your problem.
  4. Train the BPNN using the extracted activations as input and the desired outputs as targets.
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.
  2 Kommentare
Jasvin am 13 Mär. 2023
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.

Melden Sie sich an, um zu kommentieren.




Community Treasure Hunt

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

Start Hunting!

Translated by