多层前馈神经网络解决异或问题

老师给的课件算错了==

验证了一下

 1 #include<iostream>
 2 #include<string.h>
 3 //前馈神经网络解决异或问题
 4 using namespace std;
 5 int sgn(float x){
 6     if(x<0) {return 0;}
 7     else return 1;
 8 }
 9 
10 int main(){
11     //int x;
12     //cin>> x;
13     //cout <<sgn(x)<<endl;
14     int a,b;//两个输入
15     float p,q,t;//p=u11,q=u12,t=2
16     cin>>a;
17     cin>>b;
18     p = a*1+(-1)*b-0.5;
19     q = a*(-1)+1*b-0.5;
20     cout<<p<<endl;
21     cout<<q<<endl;
22     //cout<<sgn(p)<<endl;
23     //cout<<sgn(q)<<endl;
24     t=sgn(p)+sgn(q)-0.5;
25     cout<<t<<endl;
26     cout<<sgn(t)<<endl;
27 
28 return 0;
29 }
原文地址:https://www.cnblogs.com/zlz099/p/7054725.html