Hot questions for Using Neural networks in matlab figure

Question:

How can I close the two windows that the following MATLAB SOM example creates, from the command line?

>> x = simplecluster_dataset;
>> net = selforgmap([8 8]);
>> net = train(net,x);
>> view(net)
>> y = net(x);
>> classes = vec2ind(y);

Answer:

Your code opens two windows which are: Neural Network Training Window and Self-Organizing Map.

As mentioned in the documentation, nntraintool close is for closing Neural Network Training Window and as answered here, nnet.guis.closeAllViews() is for closing all diagrams of the Neural Networks.

If you are using multiple nnet guis views and want to close only a specific view, assign a handle to that particular view and then use close to close it. i.e. replace view(net) with h = view(net), now when you use, close(h), it'll close that particular nnet gui view.

Question:

I know this question may be a long shot, but is there a way to view a MATLAB neural network as a graph of vertices and edges rather than the default as below:

In other words is there a way to view it in this way within MATLAB?


Answer:

I am not sure about the format of Neural Networks Toolbox, but I can help you with the drawing part. There is a command called gplot that draws adjacency matrices (taken directly from Matlab help). You can adjust it to show circles instead of points:

k = 1:30;
[B,XY] = bucky;
gplot(B(k,k),XY(k,:),'-')
axis square
hold on ;plot(XY(k,1),XY(k,2),'o','MarkerSize',30,'MarkerFaceColor',[1 1 1])

You would need to compute XY based on the depth of your layer (not too hard), and play around a little bit with nodes (circle) size and distance between nodes.

Question:

I am trying to find the optimum number of neurons to use to run the Neural Net Fitting tool in Neural Networks Matlab app.

I am currently using 62000 samples of 64 elements as input and 62000 samples of 1 element as target. I tried to obtain similar results as in data obtained through other means, but the results are not even similar when trying to run the tool with 1-12 neurons. I tried running it with 64 neurons and the results were closer to what it was expected.

Is there any kind of way to know how many neurons to use based on the number of elements/samples?

Any suggestions on how to select the number of neurons when running the tests?

Thanks.


Answer:

Even for simple datasets like MNIST I will at minimum use 128 neurons. Possible values to check are 128, 256, 512, and maybe 1024. These numbers are just easy to remember and are not magical nor the consequence of a known formula. Alternatively, choose a few random samples from [100, 500] and see which number of neurons worked best. Harder tasks tend to require more neurons, and when you have many neurons you need to consider regularizing your network with L_2 regularization or dropout.