⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 excute.m

📁 随机神经网络工具箱
💻 M
📖 第 1 页 / 共 5 页
字号:
%   File Name      : excute.m
%   Purpose        : excution of the commands associated with buttons and menus 
%                    of the main program window  
%   Author         : Hossam E. Mostafa Abdelbaki, School of Computer Science, 
%                    University of Centeral Florida (UCF). 
%   Release        : ver. 1.0.
%   Date           : October 1998.
%
%       RNNSIM is a software program available to the user without any 
%   license or royalty fees. Permission is hereby granted to use, copy, 
%   modify, and distribute this software for any purpose. The Author 
%   and UCF give no warranty, express, implied, or statuary for the 
%   software including, without limitation, waranty of merchantibility 
%   and warranty of fitness for a particular purpose. The software 
%   provided hereunder is on an "as is"  basis, and the Author and the 
%   UCF has no obligation to provide maintenance, support, updates, 
%   enhancements, or modifications. 
%
%       RNNSIM  is available for any platform (UNIX, PCWIN, MACHITOCH). 
%   It runs under MATLAB ver. 5.0 or highrer. 
%
%       User feedback, bugs, or software and manual suggestions can 
%   be sent via electronic mail to :   ahossam@cs.ucf.edu

function excute(action)

global RnnFigHndl Checkbox1Hndl
global RnnFigallEdtsHndl RnnFigallBtnsHndl RnnFigallMnusHndl RnnFigallMainMnusHndl
global DrawNetPBHndl EditNetFilePBHndl EditTrainFilePBHndl  
global TrainPBHndl StopPBHndl PlotErrorPBHndl ResumePBHndl  
global EditTestFilePBHndl ShowLogPBHndl TestPBHndl AcceptPBHndl ResetPBHndl  
global HelpPBHndl DemoPBHndl AboutPBHndl RNNTutorialPBHndl RnnFigQuitPBHndl

global DrawNetMnuHndl EditNetFileMnuHndl EditTrainFileMnuHndl  
global TrainMnuHndl StopMnuHndl PlotErrorMnuHndl ResumeMnuHndl  
global EditTestFileMnuHndl ShowLogMnuHndl TestMnuHndl AcceptMnuHndl ResetMnuHndl  
global HelpMnuHndl DemoMnuHndl AboutMnuHndl RNNTutorialMnuHndl RnnFigQuitMnuHndl

global NetFileNameEdTHndl TrainFileNameEdTHndl WeightsFileNameEdTHndl 
global TestFileNameEdTHndl LogFileNameEdTHndl
global StartIterationStTHndl StopIterationEdTHndl;
global StartMSEStTHndl       StopMSEEdTHndl
global CurrentIterationStTHndl  CurrentMSEStTHndl
global IterationTimeStTHndl ElapsedTimeStTHndl 
global AutoSaveWeightsEdTHndl SaveIterEdTHndl
global InputNodesEdTHndl HiddenNodesEdTHndl OutputNodesEdTHndl
global LearningRateEdTHndl
global OutputRateEdTHndl  StopMSE1StTHndl
global InitialWeightsRangeEdTHndl LoadedIterEdTHndl
global LoadedMSEEdTHndl InitialWeightsRangeSliHndl
global FilePopHndl StopIteration1StTHndl 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

global NET_FLAG TRN_FLAG WTS_FLAG TST_FLAG;           
global N_Input N_Hidden N_Output N_Total Mse_Threshold MSEaveg Eta; 
global N_Iterations R_Out RAND_RANGE FIX_RIN R_IN Save_Weights;
global Net_File_Name Train_File_Name Weights_File_Name Test_File_Name;
global Log_File_Name
global Temp_Weights_File_Name Temp_Net_File_Name; 
Temp_Weights_File_Name = 'temp_wts.mat';
Temp_Net_File_Name = 'temp_net.m';
       
global N_Patterns TRAIN_INPUT TARGET TEST_INPUT N_Train_Patterns;
global wplus wminus err iter last_iter;
global STOP_FLAG WTS_FLAG_OLD WTS_FLAG_NEW;
global Hidden_Nodes_FLAG Learning_Rate_FLAG Output_Rate_FLAG 
global Stop_Iteration_FLAG Stop_MSE_FLAG;
global Save_Iter_FLAG Initial_Weight_Rage_FLAG Save_Weights_On;
global File_Pop_FLAG
global N_Saved_Iterations; 
global Temp_Save_Weights;
global  OVER_TRAINED start
global OutputFigHndl OutputFigStTHndl

switch action      
        
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
     case 'draw_net'   
         qqq = ['Draw Net  :                                           ' 
                '           Drawing the Neural Network Structure       '];
         display_message(qqq);    
         DrawNetworkFigHndl = findobj('Tag','DrawNetworkFig'); 
         if(isempty(DrawNetworkFigHndl) == 1)
            draw_nn;
            drawrnn3(N_Input,N_Hidden,N_Output);
         else 
            close(DrawNetworkFigHndl)
            draw_nn;
            drawrnn3(N_Input,N_Hidden,N_Output);
         end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%        
         
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                
     case 'edit_net'   
        qqq1 = 'Edit   :'; 
        qqq2 = '       Edit the File Containig the Network Data';
        FileName1 = get(NetFileNameEdTHndl,'String');
        qqq3 = sprintf('---->  File (%s) is opened successfully',FileName1);
        qqq4 = sprintf('---->  Invalid Network File (%s)',FileName1);
        qqq5 = sprintf('---->  Error opening File (%s)',FileName1);
        qqq6 = '---->  Check the network file name';    
        ff = check_net_file(FileName1);
        if(ff == 1)
           qqq = str2mat(qqq1,qqq2,qqq3);
           display_message(qqq);    
           comm = sprintf('edit %s',FileName1);
           eval(comm);
        end
        if(ff == 0)
           qqq = str2mat(qqq1,qqq2,qqq4);
           display_message(qqq);    
           edit;
        end
        if(ff == -1)
           qqq = str2mat(qqq1,qqq2,qqq5,qqq6);
           display_message(qqq);    
        edit;   
        end
        if(ff == -2)
           qqq = str2mat(qqq1,qqq2,qqq5,qqq6);
           display_message(qqq);    
           edit;           
        end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%        
        
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     case 'edit_train'
        qqq1 = 'Edit   :'; 
        qqq2 = '       Edit the File Containig the Train Data';
        FileName2 = get(TrainFileNameEdTHndl,'String');
        qqq3 = sprintf('---->  File (%s) is opened successfully',FileName2);
        qqq4 = sprintf('---->  Invalid Train File (%s)',FileName2);
        qqq5 = sprintf('---->  Error opening File (%s)',FileName2);
        qqq6 = '---->  Check the Train file name (.m)';    
        ff = check_trn_file(FileName2);
        if(ff == 1)
           qqq = str2mat(qqq1,qqq2,qqq3);
           display_message(qqq);    
           comm=sprintf('edit %s',FileName2);
           eval(comm);
        end
        if(ff == 0)
           qqq = str2mat(qqq1,qqq2,qqq4);
           display_message(qqq);    
           edit;
       end   
       if(ff == -1)        
          qqq = str2mat(qqq1,qqq2,qqq5,qqq6);
           display_message(qqq);    
        edit;   
        end
        if(ff == -2)
           qqq = str2mat(qqq1,qqq2,qqq5,qqq6);
           display_message(qqq);    
           edit;           
        end
       %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%        

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     case 'train'
        STOP_FLAG = 0;
        OVER_TRAINED =0;
         
         set(StopPBHndl,'Enable', 'on');
         
         set(PlotErrorPBHndl,'Enable', 'off');
         set(TrainPBHndl,'Enable', 'off');
         set(TestPBHndl,'Enable', 'off');
         set(RnnFigQuitPBHndl,'Enable', 'off');
         set(DemoPBHndl,'Enable', 'off');
         set(AboutPBHndl,'Enable', 'off');
         set(HelpPBHndl,'Enable', 'off');
         set(RNNTutorialPBHndl,'Enable', 'off');
         set(RNNTutorialPBHndl,'Enable', 'off');
         set(DrawNetPBHndl,'Enable', 'off');
         set(ResetPBHndl,'Enable', 'off');
         
         set(StopMnuHndl,'Enable', 'on');
         
         set(PlotErrorMnuHndl,'Enable', 'off');
         set(TrainMnuHndl,'Enable', 'off');
         set(TestMnuHndl,'Enable', 'off');
         set(RnnFigQuitMnuHndl,'Enable', 'off');
         set(DemoMnuHndl,'Enable', 'off');
         set(AboutMnuHndl,'Enable', 'off');
         set(HelpMnuHndl,'Enable', 'off');
         set(RNNTutorialMnuHndl,'Enable', 'off');
         set(RNNTutorialMnuHndl,'Enable', 'off');
         set(DrawNetMnuHndl,'Enable', 'off');
         set(ResetMnuHndl,'Enable', 'off');
         
         qqq1 = 'Train   :';
         qqq2 = '       Start Training the RNN';  
         qqq3 = '-----------------------------';
         qqq4 = ' Wait for network initialization';
         qqq = str2mat(qqq1,qqq2,qqq3,qqq4);
         display_message(qqq);    
         
        %prob1_trn;
        FileName1 = extract_name(Train_File_Name);
        eval(FileName1);
         prep_trn;
         prep_wts;
         
         qqq1 = 'Train   :';
         qqq2 = '       Start Training the RNN';  
         qqq3 = '-----------------------------';
         qqq4 = ' Initialization  Complete   ';
         qqq5 = ' Training in progress       ';
         qqq = str2mat(qqq1,qqq2,qqq3,qqq4,qqq5);
         display_message(qqq);    
        
         train_rnn3;
         if(OVER_TRAINED == 1)
            excute stop;
         end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%        

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     case 'stop'
         STOP_FLAG = 1;
         RESUME_FLAG = 0;
         qqq1 = 'Stop   :';
         qqq2=  '     Stop Training the RNN';  
         qqq = str2mat(qqq1,qqq2);
         display_message(qqq);    
         
         set(StopPBHndl,'Enable', 'off');
         set(TrainPBHndl,'Enable', 'off');
                 
         set(PlotErrorPBHndl,'Enable', 'on');         
         set(TestPBHndl,'Enable', 'on');
         set(RnnFigQuitPBHndl,'Enable', 'on');
         set(DemoPBHndl,'Enable', 'on');
         set(AboutPBHndl,'Enable', 'on');
         set(HelpPBHndl,'Enable', 'on');
         set(RNNTutorialPBHndl,'Enable', 'on');
         set(DrawNetPBHndl,'Enable', 'on');
         set(ResetPBHndl,'Enable', 'on');
         set(ResumePBHndl,'Enable', 'on');
         
         set(StopMnuHndl,'Enable', 'off');
         set(TrainMnuHndl,'Enable', 'off');
                 
         set(PlotErrorMnuHndl,'Enable', 'on');         
         set(TestMnuHndl,'Enable', 'on');
         set(RnnFigQuitMnuHndl,'Enable', 'on');
         set(DemoMnuHndl,'Enable', 'on');
         set(AboutMnuHndl,'Enable', 'on');
         set(HelpMnuHndl,'Enable', 'on');
         set(RNNTutorialMnuHndl,'Enable', 'on');
         set(DrawNetMnuHndl,'Enable', 'on');
         set(ResetMnuHndl,'Enable', 'on');
         set(ResumeMnuHndl,'Enable', 'on');
         
         if(OVER_TRAINED == 1 )
            if (MSEaveg <= Mse_Threshold) 
               message1 = sprintf('Current Iteration = %d',last_iter);
               message2 = sprintf('Stop Iteration = %d',N_Iterations);
               message3 = sprintf('Current MSE = %12.9f',MSEaveg);
               message4 = sprintf('Stop MSE = %12.9f',Mse_Threshold);
               message5 = sprintf('Can not Resume because Current MSE <= Stop MSE');
               message6 = sprintf('Try to reduce the value of the Stop MSE');
               message = str2mat(message1,message2,message3,message4,message5,message6);
               display_message(message);
            end
            if (iter >= N_Iterations -1) 
               message1 = sprintf('Current Iteration = %d',last_iter);
               message2 = sprintf('Stop Iteration = %d',N_Iterations);
               message3 = sprintf('Current MSE = %12.9f',MSEaveg);
               message4 = sprintf('Stop MSE = %12.9f',Mse_Threshold);
               message5 = 'Can not Resume because Current Iteration'; 
               message6 =  '>= Stop Iteration';
               message7 = 'Try to reduce the value of the Stop'; 
               message8 = 'Iteration Parameter';
               message = str2mat(message1,message2,message3,message4,message5,message6,...
                                 message7, message8);
               display_message(message);
            end
            set(ResumePBHndl,'Enable', 'off'); 
            set(ResumeMnuHndl,'Enable', 'off');             
         end
       %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%       

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     case 'plot_error'
         qqq1 = 'Plot Error   :';
         qqq2 =  '      Plot the Average Mean Squared Error';  
         qqq = str2mat(qqq1,qqq2);
         display_message(qqq);    
         if(OVER_TRAINED == 1)
            set(ResumePBHndl,'Enable', 'off');
            set(ResumeMnuHndl,'Enable', 'off');            
         else
            set(ResumePBHndl,'Enable', 'on');
            set(ResumeMnuHndl,'Enable', 'on');            
         end
         PlotErrorFigHndl = findobj('Tag','PlotErrorFig'); 
         if(isempty(PlotErrorFigHndl) == 1)
            plot_error;
            FileName = get(WeightsFileNameEdTHndl,'String');
           if(Save_Weights == 1);
              comm = sprintf('load %s err last_iter',FileName);
              eval(comm);
           else
              comm = sprintf('load %s err last_iter',Temp_Weights_File_Name );
              eval(comm);
           end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -