graphics_snn.m
来自「神经网络的工具箱, 神经网络的工具箱,」· M 代码 · 共 2,139 行 · 第 1/5 页
M
2,139 行
function fig = graphics_snn(cmd)%GRAPHICS_SNN Netpack GUIfig = -1; if strcmp(cmd, 'init') fig = init;elseif strcmp(cmd, 'welcome') clear_figure(gcf); welcome(gcf); elseif strcmp(cmd, 'import') clear_figure(gcf); import_snn(gcf);elseif strcmp(cmd, 'scaling') clear_figure(gcf); scaling(gcf);elseif strcmp(cmd, 'architecture') clear_figure(gcf); arch(gcf);elseif strcmp(cmd, 'parameters') clear_figure(gcf); parameters(gcf);elseif strcmp(cmd, 'parameter_update') parameter_update(gcf);elseif strcmp(cmd, 'ensemble') clear_figure(gcf); ensemble(gcf);elseif strcmp(cmd, 'ensemble_update') ensemble_update(gcf);elseif strcmp(cmd, 'remove') clear_figure(gcf); remove_outliers(gcf);elseif strcmp(cmd, 'remove_update') remove_update(gcf);elseif strcmp(cmd, 'average') clear_figure(gcf); average_ensemble(gcf);elseif strcmp(cmd, 'average_update') average_update(gcf);elseif strcmp(cmd, 'intervals') clear_figure(gcf); compute_intervals(gcf);elseif strcmp(cmd, 'intervals_update') intervals_update(gcf);elseif strcmp(cmd, 'predict') clear_figure(gcf); predict(gcf);elseif strcmp(cmd, 'input_relevance') clear_figure(gcf); input_relevance(gcf);else error('Unrecognized parameter for graphics_snn');endauf(gcf, 'screen', cmd);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function fig = init()screensize = get(0, 'ScreenSize');hsize = 800;vsize = 600;h0 = figure('Color',[0.8 0.8 0.8], ... 'Units', 'pixels', ... 'MenuBar','none', ... 'PaperUnits','points', ... 'Position',[(screensize(3)-hsize)/2 (screensize(4)-vsize)/2 ... hsize vsize], ... 'Tag','Fig1', ... 'ToolBar','none');fig = h0;set(fig, 'name', 'NetPack', 'numbertitle', 'off');ispc = strcmp(computer, 'PCWIN');if ispc% set(fig, 'DefaultuicontrolFontName', 'Arial Narrow'); set(fig, 'DefaultuicontrolBackgroundColor', [0.7 0.7 0.7]); set(fig, 'Position', [40 60 800 600]);end%-- File menu ----------------------------------------------------------h1 = uimenu('Parent',h0, ... 'Label','File', ... 'Tag','uimenu1');h2 = uimenu('Parent',h1, ... 'Callback','guif(''new'')', ... 'Interruptible', 'off', ... 'Label','New window', ... 'Tag','Fileuimenu1');h2 = uimenu('Parent',h1, ... 'Callback','guif(''load'')', ... 'Interruptible', 'off', ... 'Label','Load...', ... 'Tag','Fileuimenu2');h2 = uimenu('Parent',h1, ... 'Callback','guif(''save'')', ... 'Interruptible', 'off', ... 'Label','Save', ... 'Tag','Fileuimenu3');h2 = uimenu('Parent',h1, ... 'Callback','guif(''saveas'')', ... 'Interruptible', 'off', ... 'Label','Save as...', ... 'Tag','Fileuimenu4');h2 = uimenu('Parent',h1, ... 'Callback','guif(''extract'')', ... 'Interruptible', 'off', ... 'Label','Extract figure', ... 'Tag','Fileuimenu5');h2 = uimenu('Parent',h1, ... 'Callback','guif(''close'')', ... 'Interruptible', 'off', ... 'Label','Close', ... 'Tag','Fileuimenu6');%h2 = uimenu('Parent',h1, ...% 'Callback','guif(''exit'')', ...% 'Interruptible', 'off', ...% 'Label','Exit', ...% 'Tag','Fileuimenu7');%-- Action menu ----------------------------------------------------------%h1 = uimenu('Parent',h0, ...% 'Label','Action', ...% 'Tag','Action1');%h2 = uimenu('Parent',h1, ...% 'Callback','guif(''action_import'')', ...% 'Interruptible', 'off', ...% 'Label','Import training data', ...% 'Tag','ActionImport training data1');%h2 = uimenu('Parent',h1, ...% 'Label','Network architecture', ...% 'Tag','ActionArchitecture1');%h2 = uimenu('Parent',h1, ...% 'Label','Train network ensemble', ...% 'Tag','ActionTrain1');%h2 = uimenu('Parent',h1, ...% 'Label','Compute prediction intervals', ...% 'Tag','ActionCompute prediction intervals1');%h2 = uimenu('Parent',h1, ...% 'Label','Predict', ...% 'Tag','Actionuimenu1');%-- Help menu ----------------------------------------------------------h1 = uimenu('Parent',h0, ... 'Callback','guif(''help'')', ... 'Interruptible', 'off', ... 'Label','Help', ... 'Tag','uimenu2');rotate3d(h0);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function stdout(fig)stdout_struct = guf(fig, 'stdout');h0 = fig;handles.stdout = uicontrol(... 'Parent', h0, ... 'Style','list', ... 'HorizontalAlignment','left', ... 'Units', 'pixels', ... 'Min', 0, ... 'Max', 2, ... 'Value', [], ... 'Enable', 'inactive', ... 'Callback', '', ... 'Interruptible', 'off', ... 'String', '', ... 'Position',[20 20 510 72], ... 'Tag','stdout');drawnow;set(handles.stdout, 'String', stdout_struct.string);set(handles.stdout, 'ListboxTop', size(stdout_struct.string,1));auf(fig, 'handles.stdout', handles.stdout);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function welcome(fig)welcome = guf(fig, 'welcome');h0 = fig;handles.welcome.title = uicontrol('Parent',h0, ... 'Units','pixels', ... 'BackgroundColor', [0.7 0.8 0.8], ... 'FontSize',18, ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position', [20 540 510 30] , ... 'String','Welcome', ... 'Style','text', ... 'Tag','wc_title');text = {'This program can be used to train neural networks'; ... 'on regression tasks. '; ... ''; ... 'To estimate both regression and confidence intervals'; ... 'on this regression, an ensemble of networks is trained.'; ... ''; ... 'In training a so called multi-task learning approach can'; ... 'be used.'; ... ''; ... };handles.welcome.text = uicontrol('Parent',h0, ... 'Units','pixels', ... 'BackgroundColor', [0.8 0.8 0.8], ... 'HorizontalAlignment','left', ... 'Position', [20 300 510 200] , ... 'String',text, ... 'Style','text', ... 'Tag','wc_text');handles.welcome.ok = uicontrol('Parent',h0, ... 'Units','pixels', ... 'BackgroundColor',[0.7 0.7 0.7], ... 'Callback','guif(''wc_ok'')', ... 'Interruptible', 'off', ... 'ListboxTop',0, ... 'Position',[470 261 60 20], ... 'String','OK', ... 'Tag','wc_ok');handles.welcome.help = uicontrol('Parent',h0, ... 'BackgroundColor',[0.7 0.7 0.7], ... 'Callback','guif(''wc_help'')', ... 'Interruptible', 'off', ... 'ListboxTop',0, ... 'Position',[440 110 60 20], ... 'String','Help', ... 'Tag','wc_help') ;handles.welcome.next = uicontrol('Parent',h0, ... 'Enable', welcome.next.enable, ... 'BackgroundColor',[0.7 0.7 0.7], ... 'Callback','guif(''wc_next'');', ... 'Interruptible', 'off', ... 'ListboxTop',0, ... 'Position',[500 110 30 20], ... 'String','>', ... 'Tag','wc_next');handles.welcome.expframe = uicontrol('Parent',h0, ... 'Units', 'pixels', ... 'BackgroundColor',[0.7 0.7 0.7], ... 'ListboxTop',0, ... 'Position',[550 20 210 550], ... 'Style','frame', ... 'Tag','wc_expframe');text = {... '', ... '', ... '', ... '', ... '1.', ... '', ... 'In this frame you can read the', ... 'explanation of what the user should', ... 'do.', ... '', ... '', ... '2.', ... '', ... 'Press ''OK'' to continue.', ... '', ... };handles.welcome.exptext = uicontrol('Parent',h0, ... 'Units', 'pixels', ... 'Position',[560 30 190 530], ... 'Style','text', ... 'String', text, ... 'HorizontalAlignment', 'left', ... 'Tag','wc_exptext');auf(fig, 'handles.welcome', handles.welcome);stdout(fig);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function import_snn(fig)import = guf(fig, 'import');h0 = fig;handles.import.title = uicontrol('Parent',h0, ... 'Units','pixels', ... 'BackgroundColor',[0.7 0.8 0.8], ... 'FontSize', 18, ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position', [20 540 510 30] , ... 'String','Import training data', ... 'Style','text', ... 'Tag','rd_title');handles.import.text1 = uicontrol('Parent',h0, ... 'Units','pixels', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontWeight','bold', ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[20 477 104 20], ... 'String','Training datafile:', ... 'Style','text', ... 'Tag','rd_text1');handles.import.edit1 = uicontrol('Parent',h0, ... 'Units','pixels', ... 'BackgroundColor',[1 1 1], ... 'Callback','guif(''import_edit1'')', ... 'Interruptible', 'off', ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[124 480 180 20], ... 'Style','edit', ... 'String', import.filename, ... 'Tag','rd_edit1');handles.import.browse = uicontrol('Parent',h0, ... 'Units','pixels', ... 'BackgroundColor',[0.7 0.7 0.7], ... 'Callback','guif(''import_browse'')', ... 'Interruptible', 'off', ... 'ListboxTop',0, ... 'Position',[305 480 52 20], ... 'String','Browse...', ... 'Tag','rd_push1');handles.import.line1 = uicontrol('Parent',h0, ... 'Units','pixels', ... 'BackgroundColor',[0.7 0.8 0.8], ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[20 445 510 10], ... 'String','', ... 'Style','text', ... 'Tag','rd_line');handles.import.inputstext = uicontrol('Parent',h0, ... 'Enable', import.inputstext.enable, ... 'Units','pixels', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontWeight','bold', ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[20 400 125 20], ... 'String','Number of inputs:', ... 'Style','text', ... 'Tag','rd2_inputstext');handles.import.inputsedit = uicontrol('Parent',h0, ... 'Enable', import.inputsedit.enable, ... 'Units','pixels', ... 'Callback','guif(''import_inputsedit'')', ... 'Interruptible', 'off', ... 'BackgroundColor',[1 1 1], ... 'HorizontalAlignment','right', ... 'ListboxTop',0, ... 'Position',[145 403 40 20], ... 'Style','edit', ... 'String', import.inputsedit.string, ... 'Tag','rd2_inputsedit');handles.import.outputstext = uicontrol('Parent',h0, ... 'Enable', import.outputstext.enable, ... 'Units','pixels', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'FontWeight','bold', ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[20 376 125 20], ... 'String','Number of outputs:', ... 'Style','text', ... 'Tag','rd2_outputstext');handles.import.outputsedit = uicontrol('Parent',h0, ... 'Enable', import.outputsedit.enable, ... 'Units','pixels', ... 'Callback','guif(''import_outputsedit'')', ... 'Interruptible', 'off', ... 'BackgroundColor',[1 1 1], ... 'HorizontalAlignment','right', ... 'ListboxTop',0, ... 'Position',[145 379 40 20], ... 'Style','edit', ... 'String', import.outputsedit.string, ... 'Tag','rd2_outputsedit');handles.import.weights = uicontrol('Parent',h0, ... 'Enable', import.weights.enable, ... 'Units','pixels', ... 'Callback','guif(''import_check'')', ... 'Interruptible', 'off', ... 'BackgroundColor',[0.8 0.8 0.8], ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[20 355 200 20], ... 'String','datafile contains pattern weights', ... 'Style','checkbox', ... 'Value', import.weights.value, ... 'Tag','rd2_weightscheckbox');handles.import.ok = uicontrol('Parent',h0, ... 'Enable', import.ok.enable, ... 'Units','pixels', ... 'BackgroundColor',[0.7 0.7 0.7], ... 'Callback','guif(''import_ok'')', ... 'Interruptible', 'off', ... 'ListboxTop',0, ... 'Position',[470 355 60 20], ... 'String','OK', ... 'Tag','rd2_ok');handles.import.line2 = uicontrol('Parent',h0, ... 'Units','pixels', ... 'BackgroundColor',[0.7 0.8 0.8], ... 'HorizontalAlignment','left', ... 'ListboxTop',0, ... 'Position',[20 320 510 10], ... 'String','', ... 'Style','text', ... 'Tag','rd2_line');handles.import.previous = uicontrol('Parent',h0, ... 'BackgroundColor',[0.7 0.7 0.7], ... 'Callback','guif(''import_previous'')', ... 'Interruptible', 'off', ... 'ListboxTop',0, ... 'Position',[410 110 30 20], ... 'String',' < ', ... 'Tag','rd_previous');handles.import.help = uicontrol('Parent',h0, ... 'BackgroundColor',[0.7 0.7 0.7], ... 'Callback','guif(''import_help'')', ... 'Interruptible', 'off', ... 'ListboxTop',0, ... 'Position',[440 110 60 20], ... 'String','Help', ... 'Tag','rd_help');handles.import.next = uicontrol('Parent',h0, ... 'Enable', import.next.enable, ... 'BackgroundColor',[0.7 0.7 0.7], ... 'Callback','guif(''import_next'')', ... 'Interruptible', 'off', ... 'ListboxTop',0, ... 'Position',[500 110 30 20], ... 'String','>', ... 'Tag','rd_next');handles.import.expframe = uicontrol('Parent',h0, ...
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?