Question
I need to create my own initialization function for my network. I would like to use something other than INITNW and INITWB.
Expert Answer
Neeta Dsouza
PhD Expert
Answered Sep 17, 2026
When a neural network is created with NEWFF, it creates an initialization function called INITLAY. When the following code is executed:
P = [0 1 2 3 4 5 6 7 8 9 10]; T = [0 1 2 3 4 3 2 1 2 3 4]; net = newff(P,T,5); net.initFcn
The result is:
ans = initlay
This is the function that assigns the initialization function of each layer of the network to the function:
net.layers{1}.initfcn
ans =
initnw
This means that layer 1 has an initialization function 'initnw'.
To assign a custom function as the initialization function for a particular layer, simply write up the function and assign it to net.layers{1}.fcn:
net.layers{1}.initfcn = 'myfun';
That will assign the first layer's initialization function to the custom function. The rest of the layers can also be given initialization functions in the same way.
Run INIT on your network to initialize it. This basically calls INITLAY, which then calls each layer's initialization function:
init(net)
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 deep learning Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →