# MATLAB: Understanding neural networks with patternet

neural networkpatternet

Hello, i am new to neural networks and find it difficult to understand a few things about them. First of all i have created with patternet a network with 4 inputs , 3 hidden layers (4 if we consider the output also) and 3 outputs. I have several questions:
1) Is there some formula to find the nodes of each hidden layer? also can i plot so i can view them?
2) For each hidden layer can i extract vectors/struct with the weights and biases? note that i don't want the final values but instead all the values for each iteration. I have found a previous post saying to create a for loop and for each iteration extract them, but how would i know when will my nn stop, for example sometimes it stops in 30th iteration and sometimes in 50th.
3) For each iteration can i see the regression of mse? i mean to extract the actual numbers for each iteration and not to see the graph only with plotperform.
4) How can i actually save my network so when i open it i will alos have the plots of mse, confusion, plotroc and to view the structure of my network. When i save the object 'net' it saves only the matrix and when i restart my matlab i can't get all the above.
5) The correct approaching is to calculate the number of nodes, weights and biases according to this post? (Calculating biased mse etc) http://www.mathworks.com/matlabcentral/answers/78809-how-to-load-own-data-set-into-neural-network
Here is the network i created
And here is my code what i have done so far:
    net = patternnet(3);%,'trainscg','mse');    net.trainFcn = 'trainlm';    net.trainParam.epochs=2*50;  %Maximum number of epochs to train    net.trainParam.goal=0;  %Performance goal    net.trainParam.max_fail=150;  %Maximum validation failures    net.trainParam.min_grad=1e-70;  %Minimum performance gradient    net.trainParam.mu=1e-4;  %Initial mu    net.trainParam.mu_dec=0.01;  %mu decrease factor    net.trainParam.mu_inc=10;  %mu increase factor    net.trainParam.mu_max=1e10;  %Maximum mu    net.trainParam.show=25;  %Epochs between displays (NaN for no displays)    net.trainParam.showCommandLine=true;  %Generate command-line output    net.trainParam.showWindow=true;  %Show training GUI    net.trainParam.time=inf;    net = train(net,X,Target);
 greg patternnet