You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README_EN.md 6.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <div align=center><img src="./picture/01.svg"/></div>
  2. # Edge-Engine
  3. ## Edge : 一个开源的科学计算引擎
  4. [![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000) ](https://github.com/AllenZYJ/Edge-Computing-Engine/blob/add-license-1/LICENSE)![](https://img.shields.io/badge/Bulid-Version1.0-green.svg)
  5. > 项目开始日期 : 2019/10/01
  6. > 目前项目总代码 : 709 行
  7. >
  8. > 测试代码 : 810 行
  9. >
  10. > 测试环境:
  11. >
  12. > MacBook Pro
  13. >
  14. > 编译器环境:
  15. >
  16. > Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
  17. > Apple LLVM version 10.0.1 (clang-1001.0.46.4)
  18. > Target: x86_64-apple-darwin18.7.0
  19. > Thread model: posix
  20. >
  21. > 目前实现的:
  22. How to install and run the demo:
  23. `git clone git@github.com:AllenZYJ/Edge-Computing-Engine.git`
  24. `cd to this dir `
  25. `g++ main.cpp -o main`
  26. `./main`
  27. Matrix API:
  28. - [x] Matrix read_csv(string &file_path)
  29. - [x] Create a matrix : create(row,cols)
  30. - [x] Change the element for matrix void move_ele(int &ele1, int &ele2)
  31. - [x] Matrix1+Matrix2 : Matrix add(Matrix mid1,Matrix mid2,int flag=1)
  32. - [x] Flag is how to compete the ele ,default 1 ,bitwise operation(位运算加速).
  33. - [x] Matrix1-Matrix2 : Matrix subtract(Matrix mid1,Matrix mid2)
  34. - [x] Matrix1*Matrix2 : Matrix mul(Matrix mid1,Matrix mid2)
  35. - [x] Matrix1*n : Matrix times_mat(int times,Matrix mid1)
  36. - [x] Matrix1's Transposition : Matrix get_T(Matrix mid1)
  37. - [x] Mul(matrix1,matrix2)
  38. - [x] double* flatten(Matrix mid1) : Return a flattened array.
  39. - [x] Matrix matrix_rs(Matrix mid1,int rs_row,int rs_col)
  40. - [x] double matrix_sum(Matrix mid1)
  41. - [x] double matrix_mean(Matrix mid1)
  42. - [x] Matrix appply(Matrix mid1,Matrix mid2,int axis = 0)
  43. - [x] Matrix iloc(Matrix mid1,int start_x=0,int end_x=0,int start_y=0,int end_y=0)
  44. ## Demo: mat*mat
  45. Matrix **A**:
  46. | 第1列 | 第2列 | 第3列 | 第4列 | 第5列 |
  47. | ------- | ------- | ------- | ------- | ------- |
  48. | 72.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 |
  49. | 0.0000 | 64.0000 | 0.0000 | 0.0000 | 0.0000 |
  50. | 16.0000 | 8.0000 | 0.0000 | 0.0000 | 0.0000 |
  51. | 0.0000 | 0.0000 | 56.0000 | 16.0000 | 32.0000 |
  52. | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 |
  53. | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 |
  54. MAtrix **B**:
  55. | 第1列 | 第2列 | 第3列 | 第4列 | 第5列 | 第6列 |
  56. | ------- | ------- | ------- | ------- | ------ | ------ |
  57. | 72.0000 | 0.0000 | 16.0000 | 0.0000 | 0.0000 | 0.0000 |
  58. | 0.0000 | 64.0000 | 8.0000 | 0.0000 | 0.0000 | 0.0000 |
  59. | 0.0000 | 0.0000 | 0.0000 | 56.0000 | 0.0000 | 0.0000 |
  60. | 0.0000 | 0.0000 | 0.0000 | 16.0000 | 0.0000 | 0.0000 |
  61. | 0.0000 | 0.0000 | 0.0000 | 32.0000 | 0.0000 | 0.0000 |
  62. To
  63. | 第1列 | 第2列 | 第3列 | 第4列 | 第5列 | 第6列 |
  64. | --------- | --------- | --------- | --------- | ------ | ------ |
  65. | 5184.0000 | 0.0000 | 1152.0000 | 0.0000 | 0.0000 | 0.0000 |
  66. | 0.0000 | 4096.0000 | 512.0000 | 0.0000 | 0.0000 | 0.0000 |
  67. | 1152.0000 | 512.0000 | 320.0000 | 0.0000 | 0.0000 | 0.0000 |
  68. | 0.0000 | 0.0000 | 0.0000 | 4416.0000 | 0.0000 | 0.0000 |
  69. | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 |
  70. | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 |
  71. ## Demo : mat.flatten
  72. double* flatten(Matrix mid1)
  73. | 1 | 2 | 3 |
  74. | :--: | :--: | :--: |
  75. | 2 | 4 | 6 |
  76. | 7 | 8 | 9 |
  77. ​ To
  78. | 1 | 2 | 3 | 2 | 4 | 6 | 7 | 8 | 9 |
  79. | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | :----------------- |
  80. | | | | | | | | | Like numpy.flatten |
  81. ## Demo : apply nearly mat
  82. ​ Matrix appply(Matrix mid1,Matrix mid2,int axis = 0)
  83. > if axis=0 :
  84. | 0 | 7 | 2 |
  85. | ---- | ---- | ---- |
  86. | 0 | 3 | 1 |
  87. | 0 | 0 | 0 |
  88. | 0 | 0 | 11 |
  89. | 0 | 7 | 2 |
  90. | 0 | 3 | 1 |
  91. | 0 | 0 | 0 |
  92. | 0 | 0 | 11 |
  93. ------
  94. > axis = 1:
  95. | 0 | 7 | 2 | 0 | 7 | 2 |
  96. | ---- | ---- | ---- | ---- | ---- | ---- |
  97. | 0 | 3 | 1 | 0 | 3 | 1 |
  98. | 0 | 0 | 0 | 0 | 0 | 0 |
  99. | 0 | 0 | 11 | 0 | 0 | 11 |
  100. - [x] read_csv
  101. - [x] return a matrix
  102. CSV head :
  103. | -0.017612 | 14.053064 | 0 |
  104. | --------- | --------- | ---- |
  105. | -1.395634 | 4.662541 | 1 |
  106. | -0.752157 | 6.53862 | 0 |
  107. | -1.322371 | 7.152853 | 0 |
  108. | 0.423363 | 11.054677 | 0 |
  109. | 0.406704 | 7.067335 | 1 |
  110. Get:
  111. ![](./picture/WX20191119-105411@2x.png)
  112. ## Test demo:
  113. ```c
  114. #include<iostream>
  115. #include<ctime>
  116. #include<string>
  117. #include <time.h>
  118. #include <math.h>
  119. #include <fstream>
  120. #include"./matrix/matrix_def.h"
  121. #include"./matrix/matrix_pro.h"
  122. #include"./welcome/score_wel.cpp"
  123. #include"./logistic/logistic_def.h"
  124. #include"./file_pro/data_read.h"
  125. using namespace std;
  126. clock_t start, stop;
  127. double duration;
  128. int main()
  129. {
  130. welcome();
  131. string path = "./new_data2.csv";
  132. Matrix data = read_csv(path);
  133. Matrix bais = CreateMatrix(data.row,1);
  134. data = appply(data,bais,1);
  135. Matrix y = iloc(data,0,0,3,4);
  136. Matrix x_1 = iloc(data,0,0,0,3);
  137. Matrix x_2 = get_T(x_1);
  138. double alpha = 0.002;
  139. int max_epoch = 100;
  140. Matrix weight = CreateMatrix(3,1);
  141. change_va(weight,0,0,1);
  142. change_va(weight,1,0,1);
  143. change_va(weight,2,0,1);
  144. int epoch = 0;
  145. for(epoch = 0;epoch<=max_epoch;epoch++)
  146. {
  147. cout<<"-----------split-line-----------"<<endl;
  148. Matrix temp_mul = mul(x_1,weight);
  149. Matrix h =e_sigmoid(temp_mul);
  150. Matrix error = subtract(y,h);
  151. Matrix temp_update = mul(x_2,error);
  152. Matrix updata = add(weight,times_mat(alpha,temp_update),0);
  153. cout_mat(weight);
  154. cout<<"epoch: "<<epoch<<" error: "<<matrix_sum(error)<<endl;
  155. cout<<"-----------split-line-----------"<<endl;
  156. }
  157. stop = clock();
  158. printf("%f\n", (double)(stop - start) / CLOCKS_PER_SEC);
  159. return 0;
  160. }
  161. ```
  162. Something :
  163. > 1. Matrix'element is default 1
  164. > 2. Dynamically allocate memory to prevent matrix from being too large
  165. > 3. To save memory and delete later, use pointer to open up array space temporarily
  166. > 4. if free please delete(matrix);
  167. > 5. Api design like numpy or pandas
  168. > 6. Talking is cheap u can get the code
  169. > 7. welcome 🏃watched and star.
  170. >
  171. ------
  172. <div align = center><img src = './picture/星月.svg'></div>
  173. 个人小站:[极度空间](likedge.top)
  174. 作者邮箱:zk@likedge.top | edge@ibooker.org.cn
  175. QQ:2533524298

Edge : 一个开源的科学计算引擎