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

조회 수: 27 (최근 30일)
HONG CHENG
HONG CHENG 2023년 3월 2일
댓글: Jasvin 2023년 3월 13일
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/

답변 (1개)

Jasvin
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:
  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
HONG CHENG
HONG CHENG 2023년 3월 11일
  • 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 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 CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by