首页 > 行业资讯 > 【手写数字识别】基于RBM神经网络手写数字识别含Matlab源码

【手写数字识别】基于RBM神经网络手写数字识别含Matlab源码

时间:2022-04-21 来源: 浏览:

【手写数字识别】基于RBM神经网络手写数字识别含Matlab源码

天天Matlab 天天Matlab
天天Matlab

TT_Matlab

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,完整matlab代码或者程序定制加qq1575304183。

收录于话题 #图像处理matlab源码 545个

1 简介

【手写数字识别】基于RBM神经网络手写数字识别含Matlab源码

2 部分代码

function varargout = core_Test_gui2(varargin) % CORE_TEST_GUI2 MATLAB code for core_Test_gui2.fig % CORE_TEST_GUI2, by itself, creates a new CORE_TEST_GUI2 or raises the existing % singleton*. % % H = CORE_TEST_GUI2 returns the handle to a new CORE_TEST_GUI2 or the handle to % the existing singleton*. % % CORE_TEST_GUI2( ’CALLBACK’ ,hObject,eventData,handles,...) calls the local % function named CALLBACK in CORE_TEST_GUI2.M with the given input arguments. % % CORE_TEST_GUI2( ’Property’ , ’Value’ ,...) creates a new CORE_TEST_GUI2 or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before core_Test_gui2_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to core_Test_gui2_OpeningFcn via varargin. % % *See GUI Options on GUIDE ’s Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help core_Test_gui2 % Last Modified by GUIDE v2.5 17-Apr-2021 07:50:14 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct(’gui_Name’, mfilename, ... ’gui_Singleton’, gui_Singleton, ... ’gui_OpeningFcn’, @core_Test_gui2_OpeningFcn, ... ’gui_OutputFcn’, @core_Test_gui2_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 % End initialization code - DO NOT EDIT % --- Executes just before core_Test_gui2 is made visible. function core_Test_gui2_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to core_Test_gui2 (see VARARGIN) % Choose default command line output for core_Test_gui2 handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes core_Test_gui2 wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = core_Test_gui2_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; function result_Callback(hObject, eventdata, handles) % hObject handle to result (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,’ String ’) returns contents of result as text % str2double(get(hObject,’ String ’)) returns contents of result as a double % --- Executes during object creation, after setting all properties. function result_CreateFcn(hObject, eventdata, handles) % hObject handle to result (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’)) set(hObject,’BackgroundColor’,’white’); end % --- Executes on button press in classify. function classify_Callback(hObject, eventdata, handles) % hObject handle to classify (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data = handles.data; data_new=[data data]; load linear_classify_weights2;% w1为(2*22*22+1)*256,w_class为(256+1)*10 N=1; %每次只有1幅图像测试 % 下面的计算方式通过矩阵拼凑,把偏置的计算也融入矩阵中 dataprobs = [data_new ones(N,1)]; %融入偏置后dataprobs为1*(2*22*22+1) w1probs = (dataprobs*w1)>0; %未融入偏置时w1probs为1*256 w1probs = [w1probs ones(N,1)];%融入偏置后,w1probs为1*(256+1) targetout = exp(w1probs*w_class);%输出层为0*10 % 将输出层输出100*10,除以每行的总和以求得归一化比值 targetout = targetout./repmat(sum(targetout,2),1,10); % 比较每行中的最大产生10*1的列向量,I每行最大值,J每行最大值序号, % 代表识别的数字结果,1-10(分别代表数字0-9) [I J]=max(targetout,[],2); classify_result_str = num2str(J-1);%识别的结果转换为字符串 set(handles.result,’String’,classify_result_str); clear data data_new dataprobs w1probs targetout w1 w_class; % --- Executes on button press in select. function select_Callback(hObject, eventdata, handles) % hObject handle to select (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) load testbatchdata;%加载测试图像集,100*(22*22)*100 batch_index = randint(1,1,[1,100]);%产生随机批次号,1-100 image_index = randint(1,1,[1,100]);%产生该批图像中的随机测试图像号,1-100 data = testbatchdata(image_index,:,batch_index);%获取随机的一副测试图像,1*(22*22) clear testbatchdata; image_disp = zeros(22,22); image_disp = reshape(data,22,22); imagesc(image_disp’,[0 1]);%显示欲测试图像 set(handles.result,’String’,’’); handles.data = data; guidata(hObject,handles);

3 仿真结果

4 参考文献

[1]刘东泽. 基于BP神经网络的手写数字识别[D].  2011.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

版权:如无特殊注明,文章转载自网络,侵权请联系cnmhg168#163.com删除!文件均为网友上传,仅供研究和学习使用,务必24小时内删除。
相关推荐