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

📄 gene.m

📁 BP网络的图形用户界面 另附BP和遗传算法的功能,不过不好用
💻 M
📖 第 1 页 / 共 2 页
字号:
function varargout = gene(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @gene_OpeningFcn, ...
                   'gui_OutputFcn',  @gene_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% --- Executes just before gene is made visible.
function gene_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for gene
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% --- Outputs from this function are returned to the command line.
function varargout = gene_OutputFcn(hObject, eventdata, handles) 
varargout{1} = handles.output;
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
getvar(hObject, eventdata, handles);
index = get(hObject,'Value');
value = get(hObject,'UserData');
if index>1
    rangValue = minmax(value{index});
    [m,n] = size(rangValue);
    rangValue = [rangValue,zeros(m,1)];
    rangValue = num2str(rangValue);
    rangValue(:,end) = ';';    
    [m,n] = size(rangValue);
    set(handles.edit2,'String',['[',reshape(rangValue',1,m*n),'];']);
end
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
getvar(hObject, eventdata, handles);
% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
str={' 采用Levenberg-Marpuardt算法的变梯度反向传播算法',...
' 按照BFGS拟牛顿法对神经网络进行训练',...
' 按照Bayesian归一化方法对反向传播神经网络进行训练',...
' 采用Powell-Beale复位算法的变梯度反向传播训练函数',...
' 采用Fletcher-Reeves算法的变梯度反向传播训练函数',...
' 采用Polak-Ribiere算法的变梯度反向传播训练函数',...
' 采用最速梯度下降算法的反向传播训练函数',...
' 采用学习率可变的最速梯度下降算法的反向传播训练函数',...
' 以动量BP算法修正神经网络的权值和阈值',...
' 以学习率可变的动量BP算法修正神经网络的权值和阈值',...
' 以一步正切BP算法修正神经网络的权值和阈值',...
' 按随机顺序以指定的学习函数对网络进行训练',...
' 以弹性BP算法修正神经网络的权值和阈值',...
' 采用SCG算法的变梯度反向传播算法'};
set(handles.edit5,'String',str{get(hObject,'Value')});
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

% --- Executes on selection change in popupmenu3.
function popupmenu3_Callback(hObject, eventdata, handles)
str = {'加动量因子的梯度下降法权值/阈值学习函数','梯度下降法权值/阈值学习函数'};
set(handles.edit5,'String',str{get(hObject,'Value')});

% --- Executes during object creation, after setting all properties.
function popupmenu3_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu4.
function popupmenu4_Callback(hObject, eventdata, handles)
str={'均方误差','归一化均方误差','平方和误差'};
set(handles.edit5,'String',str{get(hObject,'Value')});
% --- Executes during object creation, after setting all properties.
function popupmenu4_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function edit1_Callback(hObject, eventdata, handles)
str = get(hObject,'String');
set(handles.popupmenu6,'Value',1,'String',num2str([1:str2num(str)]'),'UserData',ones(str2num(str),2));
index = get(handles.popupmenu6,'UserData');
set(handles.edit4,'String',num2str(index(1,1)));
set(handles.popupmenu7,'Value',index(1,2));
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function edit2_Callback(hObject, eventdata, handles)
function edit2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu6.
function popupmenu6_Callback(hObject, eventdata, handles)
index = get(hObject,'Value');
data = get(handles.popupmenu6,'UserData');
set(handles.edit4,'String',num2str(data(index,1)));
set(handles.popupmenu7,'Value',data(index,2));
function popupmenu6_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function edit4_Callback(hObject, eventdata, handles)
index = get(handles.popupmenu6,'Value');
data = get(handles.popupmenu6,'UserData');
data(index,1) = str2num(get(hObject,'String'));
set(handles.popupmenu6,'UserData',data);
% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu7.
function popupmenu7_Callback(hObject, eventdata, handles)
index = get(handles.popupmenu6,'Value');
data = get(handles.popupmenu6,'UserData');
data(index,2) = get(hObject,'Value');
set(handles.popupmenu6,'UserData',data);

str = {'对数S形传输函数(逻辑斯蒂曲线)','线性传输函数','双曲正切S形传输函数'};
set(handles.edit5,'String',str{get(hObject,'Value')});
% --- Executes during object creation, after setting all properties.
function popupmenu7_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in in.
function in_Callback(hObject, eventdata, handles)
getvar(hObject, eventdata, handles);
temp = get(hObject,'UserData');
set(handles.text14,'UserData',length(temp(get(hObject,'Value'))));
function in_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
getvar(hObject, eventdata, handles);
% --- Executes on selection change in out.
function out_Callback(hObject, eventdata, handles)
getvar(hObject, eventdata, handles);
temp = get(hObject,'UserData');
set(handles.text15,'UserData',length(temp(get(hObject,'Value'))));
% --- Executes during object creation, after setting all properties.
function out_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
getvar(hObject, eventdata, handles);

% --- Executes on mouse press over figure background.
function figure1_ButtonDownFcn(hObject, eventdata, handles)
set(handles.edit5,'String',get(handles.edit5,'UserData'));

function edit5_Callback(hObject, eventdata, handles)
function edit5_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function edit6_Callback(hObject, eventdata, handles)
function edit6_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function popupmenu10_Callback(hObject, eventdata, handles)
function popupmenu10_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu11.
function popupmenu11_Callback(hObject, eventdata, handles)
function popupmenu11_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu12.
function popupmenu12_Callback(hObject, eventdata, handles)
function popupmenu12_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function edit7_Callback(hObject, eventdata, handles)
function edit7_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function edit8_Callback(hObject, eventdata, handles)
function edit8_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function edit9_Callback(hObject, eventdata, handles)
function edit9_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function edit10_Callback(hObject, eventdata, handles)
function edit10_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function edit11_Callback(hObject, eventdata, handles)
function edit11_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function edit12_Callback(hObject, eventdata, handles)
function edit12_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
temp = get(handles.popupmenu6,'UserData');
nvars = sum((temp(:,1)))+prodY([get(handles.text14,'UserData');temp(:,1)]);

⌨️ 快捷键说明

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