Reply To: Extracting Trained Parameters for Fine-Tuning Insights in BRAPH 2 Neural Network

Home Forums General Help (Braph 2.0) Extracting Trained Parameters for Fine-Tuning Insights in BRAPH 2 Neural Network Reply To: Extracting Trained Parameters for Fine-Tuning Insights in BRAPH 2 Neural Network

#194791
Yu-Wei Chang
Moderator

Hi Jo-Hsin,

Thank you for your feedback on using BRAPH 2.

Absolutely, it is possible to extract the learned parameters from a trained neural network model.

Let me guide you through the process using the “example_NN_CON_WU_Classification_AdjacencyMatrix.m” script as an illustration. After line 69, kindly integrate the following code segment:


%% extract parameters and visualize model
net = classifier.get('MODEL');

% Display the layers of the network
disp("Network Layers:")
disp(net.Layers)

% Extract and display weights and biases from a specific layer
specificLayerName = 'fc1'; % Replace with the name of the desired layer
layerIndex = find(strcmp({net.Layers.Name}, specificLayerName));
specificLayer = net.Layers(layerIndex);
weights = specificLayer.Weights;
biases = specificLayer.Bias;

% Visualize the net work architecture
analyzeNetwork(net)

In this code segment, the script first displays all layers within the model. Subsequently, it extracts the parameters (weights and biases) for a specified layer (in this case, ‘fc1’ – the first fully connected layer). Finally, it provides a visual representation of the overall model architecture.

I hope this reply addresses your question. Please feel free to reach out if you require further clarification.

Best,
Yu-Wei

  • This reply was modified 7 months, 3 weeks ago by Yu-Wei Chang.
  • This reply was modified 7 months, 3 weeks ago by Yu-Wei Chang.
  • This reply was modified 7 months, 3 weeks ago by Yu-Wei Chang.
  • This reply was modified 7 months, 3 weeks ago by Yu-Wei Chang.