//f(x;W,c,w,b)=w*max{0, W*x+c}+b

#include <iostream>
#include <vector>
#include <algorithm>

template <class T>
double tanh(T& z) {
  double ret;
  ret = (exp(z)-exp((-1)*z))/(exp(z)+exp((-1)*z));
  return ret;
}

template <class T>
double sigmoid(T& z) {
  return 1.0f/(1.0f+exp((-1)*z));
}

int main() {
  int w[][2]={{1, 1}, {1,1}};
  int bias[]={0, -1};
  int weights[] = {1, -2};
  int x[][2]={{0, 0}, {0, 1}, {1, 0}, {1, 1}};
  int c[][2]={{0, 0}, {0, 0}, {0, 0}, {0, 0}};

  /*x[4][2] * w[2][2] = c[4][2]*/
  for(size_t i=0;i<4;++i) {
    for(size_t j=0;j<2;++j) {
      int sum = 0;
      for(size_t k=0;k<2;++k) {
        sum += x[i][k] * w[k][j];
      }
      c[i][j] = sum;
    }
  }

  for(size_t i=0;i<4;++i) {
    for(size_t j=0;j<2;++j) {
      std::cout<<c[i][j]<<" ";
    }
    std::cout<<std::endl;
  }

  std::cout<<"add bias, rectified linear unit:\n";

  for(size_t i=0;i<4;++i) {
    for(size_t j=0;j<2;++j) {
      c[i][j] = c[i][j] + bias[j];
      c[i][j] = std::max(c[i][j], 0);
      std::cout<<c[i][j]<<" ";
    }
    std::cout<<std::endl;
  }

  for(size_t i=0;i<4;++i) {
    for(size_t j=0;j<1;++j) {
      int sum=0;
      for(size_t k=0;k<2;++k) {
        sum += c[i][k] * weights[k];
      }
      c[i][j] = sum;
    }
  }

  std::cout<<"the XOR result:\n";
  for(size_t i=0; i<4; ++i) {
    for(size_t j=0;j<2;++j) {
      std::cout<<x[i][j]<<" ";
    }
  std::cout<<c[i][0]<<"\n";
  }

  return 0;
}

With the input patterns (0,0) and (1,1) located on opposite corners of the unit square, and likewise

for the other two input patterns (0,1) and (1,0), it is clear that we cannot construct a straight line

for a decision boundary so that (0,0) and (0,1) lie in one dicision region and (0,1) and (1,0) lie in the

other decision region. In other words, the singlelayer perceptron cannot solve the XOR problem.

最新文章

  1. J2EE项目修改编码问题
  2. MoSCoW Method
  3. Windows共享设定-使用net use添加网络盘带上账号密码
  4. SVN与TortoiseSVN实战:补丁详解
  5. Js 访问Aspnet后台页面变量
  6. AIM Tech Round (Div. 2) A. Save Luke 水题
  7. POJ:最长上升子序列
  8. python视频教程大全
  9. 默认时,销毁会话,session_unset, session_destory
  10. glide简介
  11. JavaScript常用的方法和函数(setInterval和setTimeout)
  12. 深入剖析ConcurrentHashMap二
  13. ios video标签部分mp4文件无法播放的问题
  14. MySQL DATE_SUB()
  15. node 学习(二)
  16. 1、写在开头的话——Tinking in Java 绪论之我见
  17. SAP MM MM17里不能修改物料主数据&#39;Purchasing Value Key&#39;字段值?
  18. java框架之Hibernate(4)-几种检索方式
  19. Codeforces Round #410 (Div. 2) B
  20. javaScript之表格操作&lt;一:新增行&gt;

热门文章

  1. GridView动态计算高度
  2. C# 调用win32API 获取进程句柄 有毛用???
  3. QQ空间里写的开发心得
  4. day07补充-数据类型总结及拷贝
  5. 如何创建一个项目,让gitlab自动触发jenkins进行构建
  6. CAD插入非等比例的图块
  7. PAT_A1133#Splitting A Linked List
  8. 面试bb
  9. P4047 [JSOI2010]部落划分(最小生成树)
  10. [CodeForces] CF226D The table