qq458138584 2017-11-24 12:10 采纳率: 100%

# 神经网络小白问题：训练误差太大，是程序写错了么？？？

``````0.1000    0.9000    0.9000    0.1000
0.5000    0.6000    0.6000    0.5000
``````

``````  0.2928    0.7560    0.7560    0.2929
0.3026    0.7467    0.7465    0.3023
``````

matlab代码如下

``````mat=load("mat.txt")
[m,n]=size(mat);

visible_num=n;
hidden_num=3;

out=partial2(mat,visible_num,hidden_num);
out
mat

function [out]=partial2(mat,visible_num,hidden_num)
[m,n]=size(mat);
alpha=0.1;
W2=normrnd(0,0.1,hidden_num,visible_num);
W3=normrnd(0,0.1,visible_num,hidden_num);
b2=normrnd(0,0.1,[hidden_num,1]);
b3=normrnd(0,0.1,[visible_num,1]);
%b2=zeros(hidden_num,1);
%b3=zeros(visible_num,1);
it=1000;
out=0;
for j=1:it

for i=1:m
z2=W2*mat(i,:)'+b2;
a2=sigmod(z2);
z3=W3*a2+b3;
a3=sigmod(z3);

t3=-(mat(i,:)'-a3).*(a3.*(1-a3));
t2=W3'*t3.*(a2.*(1-a2));
end

z2=W2*mat'+b2;
a2=sigmod(z2);
z3=W3*a2+b3;
a3=sigmod(z3);
err2=sum(sum(abs(mat(i,:)'-a3)))
out=a3';
end
end
function [ x ] = sigmod( x )
x=1./(1+exp(-x));
end

``````

• 写回答

#### 1条回答默认 最新

• Debug_dodge 2017-11-24 12:47
关注

输出每步的loss试试，看到底有没有下降

本回答被题主选为最佳回答 , 对您是否有帮助呢?
评论

#### 悬赏问题

• ¥15 AttributeError: 'NoneType' object has no attribute 'drop_duplicates'报错
• ¥15 编写c++计算器，用类和栈来做，要求如下
• ¥15 以下代码，运行结果报错