【手寫數(shù)字識(shí)別】基于RBM神經(jīng)網(wǎng)絡(luò)手寫數(shù)字識(shí)別含Matlab源碼
【手寫數(shù)字識(shí)別】基于RBM神經(jīng)網(wǎng)絡(luò)手寫數(shù)字識(shí)別含Matlab源碼
TT_Matlab
博主簡(jiǎn)介:擅長(zhǎng)智能優(yōu)化算法、神經(jīng)網(wǎng)絡(luò)預(yù)測(cè)、信號(hào)處理、元胞自動(dòng)機(jī)、圖像處理、路徑規(guī)劃、無人機(jī)等多種領(lǐng)域的Matlab仿真,完整matlab代碼或者程序定制加qq1575304183。
1 簡(jiǎn)介
【手寫數(shù)字識(shí)別】基于RBM神經(jīng)網(wǎng)絡(luò)手寫數(shù)字識(shí)別含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幅圖像測(cè)試
%
下面的計(jì)算方式通過矩陣拼湊,把偏置的計(jì)算也融入矩陣中
dataprobs = [data_new ones(N,1)]; %融入偏置后dataprobs為1*(2*22*22+1)
w1probs = (dataprobs*w1)>0; %未融入偏置時(shí)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);
%
比較每行中的最大產(chǎn)生10*1的列向量,I每行最大值,J每行最大值序號(hào),
%
代表識(shí)別的數(shù)字結(jié)果,1-10(分別代表數(shù)字0-9)
[I J]=max(targetout,[],2);
classify_result_str = num2str(J-1);%識(shí)別的結(jié)果轉(zhuǎn)換為字符串
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;%加載測(cè)試圖像集,100*(22*22)*100
batch_index = randint(1,1,[1,100]);%產(chǎn)生隨機(jī)批次號(hào),1-100
image_index = randint(1,1,[1,100]);%產(chǎn)生該批圖像中的隨機(jī)測(cè)試圖像號(hào),1-100
data = testbatchdata(image_index,:,batch_index);%獲取隨機(jī)的一副測(cè)試圖像,1*(22*22)
clear testbatchdata;
image_disp = zeros(22,22);
image_disp = reshape(data,22,22);
imagesc(image_disp’,[0 1]);%顯示欲測(cè)試圖像
set(handles.result,’String’,’’);
handles.data = data;
guidata(hObject,handles);
3 仿真結(jié)果
4 參考文獻(xiàn)
[1]劉東澤. 基于BP神經(jīng)網(wǎng)絡(luò)的手寫數(shù)字識(shí)別[D]. 2011.
博主簡(jiǎn)介:擅長(zhǎng)智能優(yōu)化算法、神經(jīng)網(wǎng)絡(luò)預(yù)測(cè)、信號(hào)處理、元胞自動(dòng)機(jī)、圖像處理、路徑規(guī)劃、無人機(jī)等多種領(lǐng)域的Matlab仿真,相關(guān)matlab代碼問題可私信交流。
部分理論引用網(wǎng)絡(luò)文獻(xiàn),若有侵權(quán)聯(lián)系博主刪除。
-
2023年各省最新電價(jià)一覽!8省中午執(zhí)行谷段電價(jià)! 2023-01-03
-
PPT導(dǎo)出高分辨率圖片的四種方法 2022-09-22
-
全國(guó)消防救援總隊(duì)主官及簡(jiǎn)歷(2023.2) 2023-02-10
-
我們的前輩!歷屆全國(guó)工程勘察設(shè)計(jì)大師完整名單! 2022-11-18
-
關(guān)于某送變電公司“4·22”人身死亡事故的快報(bào) 2022-04-26
