Reuse of Weights and Biases in CNN
1 view (last 30 days)
Show older comments
Hello everyone, I have applied a 1D CNN to a training dataset with dimensions 60095×39 and obtained the attached network. Now, I would like to extract the weights and biases corresponding to feature 2 (column 2) and then retrain the network using only feature 2 with dimensions 60095×1, utilizing the weights from the previous training. Could you please guide me on how to achieve this?
You can find the attached network.
Thanks in advance.
1 Comment
Debraj Maji
on 21 Nov 2023
Edited: Debraj Maji
on 24 Nov 2023
Can you please clarify on what is meant by weights and biases corresponding to feature 2?
Answers (1)
Ayush
on 5 Dec 2023
Edited: Ayush
on 5 Dec 2023
Hey Hamza,
I understand that you have a trained network with 39 features and 60095 data points. You want to extract the weights and biases corresponding to feature 2 (column 2) from the trained network. After extracting these parameters, you aim to retrain the new network using only feature 2 data with dimensions 60095×1, while utilizing the weights from the previous training.
To extract the weights and biases corresponding to feature 2 from the trained network, you can access these parameters using the network's property fields. Here's an example of how you might extract the weights and biases for feature 2 in MATLAB:
% Assuming your trained network is named 'trainedNet
weightsLayer2 = trainedNet.Layers(2).Weights; % Extract weights for the second layer
biasesLayer2 = trainedNet.Layers(2).Bias; % Extract biases for the second layer
For retraining the network using feature-2 , you can follow these steps:
- Prepare Feature-2 data: Prepare your training dataset using only feature 2 with dimensions 60095×1.
- Create a new network. You can use functions like “feedforwardnet” for this operation.
- Set the weights and biases of the network using properties again.
- Training the new network using “train” function .
For more information on “feedforwardnet” and “train” , refer to the MathWorks documentation link below:
- https://www.mathworks.com/help/deeplearning/ref/feedforwardnet.html
- https://www.mathworks.com/help/deeplearning/ref/network.train.html
Hope this helps!
Regards,
Ayush Goyal
0 Comments
See Also
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!