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

28 visualizaciones (últimos 30 días)
HONG CHENG
HONG CHENG el 2 de Mzo. de 2023
Comentada: Jasvin el 13 de Mzo. de 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
https://github.com/meton-robean/SPO_BPNN_PID/

Respuestas (1)

Jasvin
Jasvin el 9 de Mzo. de 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 comentarios
HONG CHENG
HONG CHENG el 11 de Mzo. de 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.
That's right. Thank you for your answer. But I just consider changing the structure of the network. To use a SPO_BPNN_PID model with image inputs, CNNs are the best choice.
It seems that I have to find some cnn layer functions such as activation function, conv layer and pooling layer from scrach.
Jasvin
Jasvin el 13 de Mzo. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by