Question
How do I extract and display weight matrices of hidden layers in a trained MATLAB neural network model?
Expert Answer
Neeta Dsouza
PhD Expert
Answered Aug 24, 2026
In Deep Learning Toolbox, you can extract weight matrices using net.IW (Input Weights) and net.LW (Layer Weights) or net.Layers for SeriesNetwork/DAGNetwork objects:
% For standard Feedforward Neural Network (net):
W1 = net.IW{1,1}; % Weights from input to 1st hidden layer
figure;
imagesc(W1);
colorbar;
title('Hidden Layer 1 Weight Matrix');
xlabel('Inputs'); ylabel('Neurons');
% For Deep Convolutional Networks (net):
convLayer = net.Layers(2);
W_conv = convLayer.Weights; % Size: [H W C Filters]
montage(rescale(W_conv));
title('Visualized Conv Filter Weights');
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related MATLAB Deep Learning Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →