graphics_snn.m

来自「神经网络的工具箱, 神经网络的工具箱,」· M 代码 · 共 2,139 行 · 第 1/5 页

M
2,139
字号
        'Units', 'pixels', ...        'BackgroundColor',[0.7 0.7 0.7], ...        'ListboxTop',0, ...        'Position',[550 20 210 550], ...        'Style','frame', ...        'Tag','rd_expframe');text = {...        '', ...        '', ...        '1. ', ...        '', ...	'Insert the name of a ascii file containing training data.', ...        'This file must be formatted as follows:', ...        '', ...        'Each pattern is on a seperate line. Each', ...	'line consists of space separated values.', ...	'These values must be (in this order): ', ...	'inputs, outputs and (optionally) pattern', ...	'weights. To indicate missing values in ', ...	'the output the string ''NaN'' must be used.', ...	'', ...	'For example, 3 patterns, consisting of', ...	'one input and 2 outputs, where for ', ...	'pattern 1 and pattern 3 an output is ,'...	'unknown, must be formatted as:', ...	'', ...	'   0.2 NaN 0.3 1', ...        '   0.1 0.6 0.2 2', ...        '   0.3 0.2 NaN 1', ...	'', ...	'Inputs are in column 1. Outputs are in', ...	'colum 2 and 3. Pattern 2 is weighted', ...	'twice (see column 4)', ...	'', ...	'', ...	'2.', ...	'', ...	'After the data file is read, insert', ...	'the number of inputs and outputs.', ...	'If the patterns contain pattern weights,', ...	'mark the checkbox', ...	'', ...	'3.', ...	'', ...	'Press ''OK'' to continue.', ...        };handles.import.exptext = uicontrol('Parent',h0, ...        'Units', 'pixels', ...        'Position',[560 30 190 530], ...        'Style','text', ...	'String', text, ...	'HorizontalAlignment', 'left', ...        'Tag','rd_exptext');auf(fig, 'handles.import', handles.import);stdout(fig);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function scaling(fig)scaling = guf(fig, 'scaling');arch = guf(fig, 'arch');h0 = fig;handles.scaling.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','Scaling', ...	'Style','text', ...	'Tag','sc_title');poptext = [arch.inputnames; arch.outputnames];handles.scaling.pop = ...       uicontrol('Parent',h0, ...	'Units','pixels', ...	'Callback','guif(''scaling_pop'')', ...	'Interruptible', 'off', ...	'HorizontalAlignment','left', ...	'ListboxTop',1, ...	'Position', [20 500 100 20], ...	'String', poptext, ...	'Style','popup', ...	'Tag','sc_transpop', ...        'Value', scaling.pop.value, ...	'Visible','on');handles.scaling.meanzero = uicontrol('Parent',h0, ...	'BackgroundColor',[0.7 0.7 0.7], ...	'Callback','guif(''scaling_meanzero'')', ...	'Interruptible', 'off', ...	'ListboxTop',0, ...	'Position',[20 460 50 20], ...	'String',' <x>=0 ', ...	'Tag','sc_meanzero');handles.scaling.stdone = uicontrol('Parent',h0, ...	'BackgroundColor',[0.7 0.7 0.7], ...	'Callback','guif(''scaling_stdone'')', ...	'Interruptible', 'off', ...	'ListboxTop',0, ...	'Position',[70 460 50 20], ...	'String',' std(x)=1 ', ...	'Tag','sc_stdone');handles.scaling.zeroone = uicontrol('Parent',h0, ...	'BackgroundColor',[0.7 0.7 0.7], ...	'Callback','guif(''scaling_zeroone'')', ...	'Interruptible', 'off', ...	'ListboxTop',0, ...	'Position',[120 460 50 20], ...	'String',' 0<x<1 ', ...	'Tag','sc_zeroone');handles.scaling.moneone = uicontrol('Parent',h0, ...	'BackgroundColor',[0.7 0.7 0.7], ...	'Callback','guif(''scaling_moneone'')', ...	'Interruptible', 'off', ...	'ListboxTop',0, ...	'Position',[170 460 50 20], ...	'String',' -1<x<1 ', ...	'Tag','sc_moneone');handles.scaling.inv = uicontrol('Parent',h0, ...	'BackgroundColor',[0.7 0.7 0.7], ...	'Callback','guif(''scaling_inv'')', ...	'Interruptible', 'off', ...	'ListboxTop',0, ...	'Position',[220 460 50 20], ...	'String',' 1/x ', ...	'Tag','sc_inv');handles.scaling.sqrt = uicontrol('Parent',h0, ...	'BackgroundColor',[0.7 0.7 0.7], ...	'Callback','guif(''scaling_sqrt'')', ...	'Interruptible', 'off', ...	'ListboxTop',0, ...	'Position',[270 460 50 20], ...	'String','sqrt(x)', ...	'Tag','sc_sqrt');handles.scaling.log = uicontrol('Parent',h0, ...	'BackgroundColor',[0.7 0.7 0.7], ...	'Callback','guif(''scaling_log'')', ...	'Interruptible', 'off', ...	'ListboxTop',0, ...	'Position',[320 460 50 20], ...	'String','log(x)', ...	'Tag','sc_log');handles.scaling.exp = uicontrol('Parent',h0, ...	'BackgroundColor',[0.7 0.7 0.7], ...	'Callback','guif(''scaling_exp'')', ...	'Interruptible', 'off', ...	'ListboxTop',0, ...	'Position',[370 460 50 20], ...	'String','exp(x)', ...	'Tag','sc_exp');handles.scaling.undo = uicontrol('Parent',h0, ...	'BackgroundColor',[0.7 0.7 0.7], ...	'Callback','guif(''scaling_undo'')', ...	'Interruptible', 'off', ...	'ListboxTop',0, ...	'Position',[470 460 60 20], ...	'String','Undo', ...	'Tag','sc_undo');readdata = guf(fig, 'readdata');handles.scaling.ax1 = axes('Parent',h0', ...         'Units', 'pixels', ...	 'Position', [40 280 150 150], ...	 'Tag', 'sc_ax1', ...	 'Visible', 'on');         hist(readdata(:, scaling.pop.value));handles.scaling.scalingtext = uicontrol('Parent',h0, ...	'Units','pixels', ...	'BackgroundColor',[0.8 0.8 0.8], ...	'FontWeight','bold', ...	'HorizontalAlignment','left', ...	'ListboxTop',0, ...	'Position',[20 220 100 20], ...	'String','Scaling:', ...	'Style','text', ...	'Tag','sc_scalingtext');scale = guf(fig, 'scale');sc = scale{scaling.pop.value};if (isempty(sc))    handles.scaling.sctext = uicontrol('Parent',h0, ...	'Units','pixels', ...	'BackgroundColor',[0.8 0.8 0.8], ...	'HorizontalAlignment','left', ...	'ListboxTop',0, ...	'Position',[80 220 100 20], ...	'String','- none -', ...	'Style','text', ...	'Tag','sc_sctext');else   sctext = ['- ' ];   for i = 1:prod(size(sc))       sctext = [sctext sc(i).name ' - '];   end   handles.scaling.sctext = uicontrol('Parent',h0, ...	'Units','pixels', ...	'BackgroundColor',[0.8 0.8 0.8], ...	'HorizontalAlignment','left', ...	'ListboxTop',0, ...	'Position',[80 220 500 20], ...	'String', sctext, ...	'Style','text', ...	'Tag','sc_sctext');   handles.scaling.ax2 = axes('Parent',h0', ...         'Units', 'pixels', ...	 'Position', [310 280 150 150], ...	 'Tag', 'sc_ax1', ...	 'Visible', 'on');         hist(scale_snn(readdata(:, scaling.pop.value), sc));endhandles.scaling.ok = uicontrol('Parent',h0, ...        'Units','pixels', ...	'BackgroundColor',[0.7 0.7 0.7], ...	'Callback','guif(''scaling_ok'')', ...	'Interruptible', 'off', ...	'ListboxTop',0, ...	'Position',[470 140 60 20], ...	'String','OK', ...	'Tag','sc_ok');handles.scaling.previous = uicontrol('Parent',h0, ...	'BackgroundColor',[0.7 0.7 0.7], ...	'Callback','guif(''scaling_previous'')', ...	'Interruptible', 'off', ...	'ListboxTop',0, ...	'Position',[410 110 30 20], ...	'String',' < ', ...	'Tag','sc_previous');handles.scaling.help = uicontrol('Parent',h0, ...	'BackgroundColor',[0.7 0.7 0.7], ...	'Callback','guif(''scaling_help'')', ...	'Interruptible', 'off', ...	'ListboxTop',0, ...	'Position',[440 110 60 20], ...	'String','Help', ...	'Tag','sc_help') ;handles.scaling.next = uicontrol('Parent',h0, ...        'Enable', scaling.next.enable, ...	'BackgroundColor',[0.7 0.7 0.7], ...	'Callback','guif(''scaling_next'');', ...	'Interruptible', 'off', ...	'ListboxTop',0, ...	'Position',[500 110 30 20], ...	'String','>', ...	'Tag','sc_next');handles.scaling.expframe = uicontrol('Parent',h0, ...        'Units', 'pixels', ...        'BackgroundColor',[0.7 0.7 0.7], ...        'ListboxTop',0, ...        'Position',[550 20 210 550], ...        'Style','frame', ...        'Tag','sc_expframe');text = {...        '', ...        '', ...        '', ...        '', ...        '1.', ...        '', ...        'Select input or output.', ...        '', ...        '2.', ...        '', ...        'Choose scaling.', ...        '', ...        '3.', ...        '', ...        'Press ''OK'' to continue.', ...        '', ...        };handles.scaling.exptext = uicontrol('Parent',h0, ...        'Units', 'pixels', ...        'Position',[560 30 190 530], ...        'Style','text', ...	'String', text, ...	'HorizontalAlignment', 'left', ...        'Tag','sc_exptext');auf(fig, 'handles.scaling', handles.scaling);stdout(fig);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function arch(fig)arch = guf(fig, 'arch');import = guf(fig, 'import');h0 = fig;handles.arch.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','Network architecture', ...	'Style','text', ...	'Tag','arch_title');handles.arch.layertext = uicontrol('Parent',h0, ...	'Units','pixels', ...	'BackgroundColor',[0.8 0.8 0.8], ...	'FontWeight','bold', ...	'HorizontalAlignment','left', ...	'ListboxTop',0, ...	'Position',[20 501 155 20], ...	'String','Number of hidden layers:', ...	'Style','text', ...	'Tag','arch_nhltext');handles.arch.layeredit = uicontrol('Parent',h0, ...	'Units','pixels', ...	'Callback','guif(''arch_layeredit'')', ...	'Interruptible', 'off', ...	'BackgroundColor',[1 1 1], ...	'HorizontalAlignment','right', ...	'ListboxTop',0, ...	'Position',[175 505 40 20], ...	'Style','edit', ...        'String', num2str(arch.nlayers), ...	'Tag','arch_layeredit');handles.arch.dynamic.axes = axes(...         'Units', 'pixels', ...	 'Position', [80 220 390 260], ...	 'Tag', 'arch_picture', ...	 'Visible', 'off');         inputs = str2num(import.inputsedit.string);         outputs = str2num(import.outputsedit.string);         network_picture_snn([inputs arch.nunits outputs]);         axis('off');L = arch.nlayers;handles.arch.dynamic.inputnamestext = ...       uicontrol('Parent',h0, ...	'Units','pixels', ...	'BackgroundColor',[0.8 0.8 0.8], ...	'FontWeight','bold', ...	'HorizontalAlignment','left', ...	'ListboxTop',0, ...	'Position',[20 476 135 20], ...	'String','Input names:', ...	'Style','text', ...	'Tag','arch_inputnamestext', ...	'Visible','on');nmax = max(max(inputs, outputs),2);dy = 0.9/(nmax-1);for i = 1:inputs    y0 = (220+260) - 260*(0.5 + dy*(i - (inputs+1)/2));     Position = [20 (y0 - 20/2) 70 20];    handles.arch.dynamic.inputnamesedit(i) = ...       uicontrol('Parent',h0, ...	'Units','pixels', ...	'Callback','guif(''arch_inputnamesedit'')', ...	'Interruptible', 'off', ...	'BackgroundColor',[1 1 1], ...	'HorizontalAlignment','left', ...	'ListboxTop',0, ...	'Position', Position, ...	'String', arch.inputnames(i), ...	'Style','edit', ...	'Tag','arch_inputnamesedit', ...        'UserData', i, ...	'Visible','on');endhandles.arch.dynamic.outputnamestext = ...      uicontrol('Parent',h0, ...	'Units','pixels', ...	'BackgroundColor',[0.8 0.8 0.8], ...	'FontWeight','bold', ...	'HorizontalAlignment','left', ...	'ListboxTop',0, ...	'Position',[430 476 100 20], ...	'String','Output names:', ...	'Style','text', ...	'Tag','arch_outputnamestext', ...	'Visible','on');nmax = max(max(inputs, outputs),2);dy = 0.9/(nmax-1);for i = 1:outputs    y0 = (220+260) - 260*(0.5 + dy*(i - (outputs+1)/2));     Position = [460 (y0 - 20/2) 70 20];    handles.arch.dynamic.outputnamesedit(i) = ...       uicontrol('Parent',h0, ...	'Units','pixels', ...	'Callback','guif(''arch_outputnamesedit'')', ...	'Interruptible', 'off', ...	'BackgroundColor',[1 1 1], ...	'HorizontalAlignment','left', ...	'ListboxTop',0, ...	'Position', Position, ...	'String', arch.outputnames(i), ...	'Style','edit', ...	'Tag','arch_outputnamesedit', ...        'UserData', i, ...	'Visible','on');endhandles.arch.dynamic.hiddenstext = ...        uicontrol('Parent',h0, ...	'Units','pixels', ...	'BackgroundColor',[0.8 0.8 0.8], ...	'FontWeight','bold', ...	'HorizontalAlignment','left', ...	'ListboxTop',0, ...	'Position',[20 196 145 20], ...	'String','Number of hidden units:', ...	'Style','text', ...	'Tag','arch_nhutext', ...	'Visible','on');dx = 0.9/(L+1);for i = 1:L    l = i+1;    x0 = 80 + 390*(0.5 + dx*(l - (L+3)/2));     Position = [(x0- 40/2) 200 40 20];    handles.arch.dynamic.layeredit(i) = ...        uicontrol('Parent',h0, ...	'Units','pixels', ...	'Callback','guif(''arch_unitedit'')', ...	'Interruptible', 'off', ...	'BackgroundColor',[1 1 1], ...	'HorizontalAlignment','right', ...	'ListboxTop',0, ...	'Position', Position, ...	'String', num2str(arch.nunits(i)), ...	'Style','edit', ...	'Tag','arch_unitedit', ...        'UserData', i, ...	'Visible','on');

⌨️ 快捷键说明

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