bp 이용한 매트랩코딩

kiki10184의 이미지

데이터 x를 받아서 t랑 비교후 글자를 인식하느냐안하느냐를 프밍하고 있는데
계속 오류가 나네요 ..뭐가 잘못된건지...도와주세요 ㅠㅠ

x=zeros(7,63);
% Input from Font1
x =[0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 1 1 1 1 1 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 1 1 1 0 1 1 1; % A
1 1 1 1 1 1 0 0 1 0 0 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 1 0 1 1 1 1 1 0 0 1 0 0 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 1 1 1 1 1 1 1 0; % B
0 0 1 1 1 1 1 0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 1 1 1 0; % C
1 1 1 1 1 0 0 0 1 0 0 0 1 0 0 1 0 0 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 1 0 1 1 1 1 1 0 0; % D
1 1 1 1 1 1 1 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 1 1 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 1 1 1 1 1 1 1; % E
0 0 0 1 1 1 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 0 1 1 1 0 0; % J
1 1 1 0 0 1 1 0 1 0 0 1 0 0 0 1 0 1 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 1 0 1 1 1 0 0 1 1]; % K

t=[1 -1 -1 -1 -1 -1 -1; % A
-1 1 -1 -1 -1 -1 -1; % B
-1 -1 1 -1 -1 -1 -1; % C
-1 -1 -1 1 -1 -1 -1; % D
-1 -1 -1 -1 1 -1 -1; % E
-1 -1 -1 -1 -1 1 -1; % J
-1 -1 -1 -1 -1 -1 1]; % K

iv=rand(63,63)-0.5;ibh=rand(1,7)-0.5;
iw=rand(1,7)-0.5;ibo=rand(1,1)-0.5;

w=iw;v=iv;bh=ibh;bo=ibo;
st=1;ct=0;alpa=0.05;th=0.2;
count=0; mse=0;

while st == 1 && count < 5000
mse=0;st=0;

for m=1:7
% net input to the hidden unit
zin=zeros(7,63);z=zeros(7,63);
for i=1:7
for j=1:63
temp=x(m,j)*v(j,i);
zin(i)=zin(i)+temp;
end
zin(i)=zin(i)+bh(i);
z(i)=2/(1+exp(-zin(i)))-1;
end
% net input to the output unit
yin=0;
for i=1:7
temp=w(i)*z(i);
yin=yin+temp;
end
yin=yin+bo;
yta=2/(1+exp(-yin))-1;
% error portion
e=t(m)-yta;
do=e*(1-yta^2)/2;

dh=zeros(7,63);
for i=1:7
dh(i)=do*w(i)*(1-z(i)^2)/2;
end
% weight changes
for i=1:7
w(i)=w(i)+alpa*do*z(i);
end
bo=bo+alpa*do;
for i=1:7
for j=1:63
v(j,i)=v(j,i)+alpa*dh(i)*x(m,j);
end
bh(i)=bh(i)+alpa*dh(i);
end
% stopping condition
mse=mse+e^2;
if abs(e) > 0.1
st=1;
end
end
count=count+1;
msee(count)=mse/4;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% if rem(count,1000) == 0 & st == 1
% count
% disp('system response');
% for m=1:7
% zin=zeros(7,63);z=zeros(7,63);
% for i=1:7
% for j=1:63
% temp=x(m,j)*v(j,i);
% zin(i)=zin(i)+temp;
% end
% zin(i)=zin(i)+bh(i);
% z(i)=2/(1+exp(-zin(i)))-1;
% end
% yin=0;
% for i=1:7
% temp=w(i)*z(i);
% yin=yin+temp;
% end
% yin=yin+bo;
% yta=2/(1+exp(-yin))-1;
% [x(m,1) x(m,2) yta]
% end
% end

end

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.