Oladoyin asked . 2021-08-05

NARX OPTIMUM HIDDEN NODES NUMBER

I used the code below to try to get the optimum number of hidden nodes for a narx network....I would like any suggestions concerning if I am implementing the code correctly. THANKS
 
 
        close all,clear all, clc, plt=0;

          tic

         load 'ProjectD'

        X = GasProduced; %[1x1500] cell
        T = OilRate;     %[1x1500] cell

         x  = cell2mat(X);
         t  = cell2mat(T);

         [ I N ] = size(X);           % [ 1 1500]
         [ O N ] = size(T);

        MSE00 = mean(var(t',1)) % 1.1197e+07
        MSE00a = mean(var(t',0)) %1.12041e+07

        %Normalization

        zx = zscore(cell2mat(X), 1);
        zt = zscore(cell2mat(T), 1);

            Ntrn = N-2*round(0.15*N)  
            trnind = 1:Ntrn
            Ttrn = T(trnind)

        Neq     = prod(size(Ttrn))     % 1500

        %Significant Lags were determined using the code at :

        <http://www.mathworks.com/matlabcentral/newsreader/view_thread/341287#935393>

        %sigilag95: [0:517 520 521 524 525 636:1255 1345:1384] %Significant Input Lag

        %sigflag95: [0:348 411:1207 1321:1401]  %significant Feedback lag

        rng('default')

        % %  
        % %  

FD   = 1:20; %Random Selection of sigflag subset

ID   = 1:20; %Random selection of sigilag subset

   NFD  = length(FD)   % 

   NID  = length(ID)  %

MXFD  = max(FD)      

   MXID = max(ID)

Ntrneq = prod(size(t))

   %  Nw =  ( NID*I + NFD*O + 1)*H + ( H + 1)*O

   Hub     =  -1+ceil( (Ntrneq-O) / ((NID*I)+(NFD*O)+1))  

    Hmax    =  floor(Hub/10) %  

    Hmax = 2 ==>  Nseq >>Nw :
           Hmin    = 0
           dH      = 1
           Ntrials = 25
           j=0
           rng(4151941)
           for h = Hmin:dH:Hmax
              j = j+1
              if h == 0
                  net = narxnet( ID, FD, [] );
                  Nw =  ( NID*I + NFD*O + 1)*O
              else
                  net = narxnet( ID, FD, h );
                  Nw =  ( NID*I + NFD*O + 1)*h + ( h + 1)*O
              end
              Ndof            = Ntrn-Nw
              [ Xs Xi Ai Ts ] = preparets(net,X,{},T);
              ts              = cell2mat(Ts);
              xs              = cell2mat(Xs);
              MSE00s          = mean(var(ts',1))
              MSE00as         = mean(var(ts'))
              MSEgoal         = 0.01*Ndof*MSE00as/Neq
              MinGrad         = MSEgoal/10
              net.trainParam.goal      =  MSEgoal;
              net.trainParam.min_grad  =  MinGrad;
              net.divideFcn            =  'dividetrain';
              for i = 1:Ntrials
                  net            =  configure(net,Xs,Ts);
                  [ net tr Ys ]  =  train(net,Xs,Ts,Xi,Ai);
                  ys             =  cell2mat(Ys);
                  stopcrit{i,j}  = tr.stop;
                  bestepoch(i,j) = tr.best_epoch;
                  MSE            = mse(ts-ys);
                  MSEa           = Neq*MSE/Ndof;
                  R2(i,j)        = 1-MSE/MSE00s; 
                  R2a(i,j)       = 1-MSEa/MSE00as;
              end
           end
           stopcrit   =  stopcrit    %Min grad reached (for all).
           bestepoch  =  bestepoch
           R2         =  R2
           R2a        =  R2a
           Totaltime  =  toc

 

narxnet , neural , hub , neural network

Expert Answer

Neeta Dsouza answered . 2024-12-20 18:59:01

I get the same results as you.
1. However, there are some code inconsistencies including:
  • a. Using Ntrn = 70 with 'dividetrain'
  • b. Not taking lags into account when counting equations... the equation count should be based on ttrns.
2. I now find using o (instead of s) and c as subscripts for openloop and closeloop to be more natural.
3. Sorry for not suggesting
  • a. less trivial dataset examples like simpleseries and pollution.
  • b. Using ID = 0
3. Remember, DIVIDETRAIN is only recommended for estimating the minimum values of ID, FD, and H that will yield acceptable performance. To get reliable estimates of performance on unseen data use data division with Ntrn as small as possible.


Not satisfied with the answer ?? ASK NOW

Frequently Asked Questions

MATLAB offers tools for real-time AI applications, including Simulink for modeling and simulation. It can be used for developing algorithms and control systems for autonomous vehicles, robots, and other real-time AI systems.

MATLAB Online™ provides access to MATLAB® from your web browser. With MATLAB Online, your files are stored on MATLAB Drive™ and are available wherever you go. MATLAB Drive Connector synchronizes your files between your computers and MATLAB Online, providing offline access and eliminating the need to manually upload or download files. You can also run your files from the convenience of your smartphone or tablet by connecting to MathWorks® Cloud through the MATLAB Mobile™ app.

Yes, MATLAB provides tools and frameworks for deep learning, including the Deep Learning Toolbox. You can use MATLAB for tasks like building and training neural networks, image classification, and natural language processing.

MATLAB and Python are both popular choices for AI development. MATLAB is known for its ease of use in mathematical computations and its extensive toolbox for AI and machine learning. Python, on the other hand, has a vast ecosystem of libraries like TensorFlow and PyTorch. The choice depends on your preferences and project requirements.

You can find support, discussion forums, and a community of MATLAB users on the MATLAB website, Matlansolutions forums, and other AI-related online communities. Remember that MATLAB's capabilities in AI and machine learning continue to evolve, so staying updated with the latest features and resources is essential for effective AI development using MATLAB.

Without any hesitation the answer to this question is NO. The service we offer is 100% legal, legitimate and won't make you a cheater. Read and discover exactly what an essay writing service is and how when used correctly, is a valuable teaching aid and no more akin to cheating than a tutor's 'model essay' or the many published essay guides available from your local book shop. You should use the work as a reference and should not hand over the exact copy of it.

Matlabsolutions.com provides guaranteed satisfaction with a commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been empanelled after extensive research and quality check.

Matlabsolutions.com provides undivided attention to each Matlab assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work done at the best price in industry.