Advertisement
Guest User

Untitled

a guest
Jan 29th, 2015
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.29 KB | None | 0 0
  1. //###########################
  2. //## Paweł Kalinowski ##
  3. //## S11348 ##
  4. //###########################
  5. using System;
  6. using System.Collections;
  7.  
  8. namespace SimplePerceptronNetBEP.Classes.TestValues
  9. {
  10. class NeuralNetworkTestData
  11. {
  12. internal class TestSet
  13. {
  14. public double[] input;
  15. public double[] output;
  16.  
  17. public TestSet(double[] inpuDoubles, double[] outpuDoubles)
  18. {
  19. input = inpuDoubles;
  20. output = outpuDoubles;
  21. }
  22. }
  23.  
  24. private readonly ArrayList lst;
  25. private readonly Random rand;
  26.  
  27. //poprawne
  28. private readonly double[] _test1Input =
  29. {
  30. 1, 0, 0, 0, 0, 0, 0, 0, 0,
  31. 0, 0, 0, 1, 0, 0, 0, 0, 0,
  32. 1, 0, 0, 1, 0, 0, 0, 1, 0,
  33. 0, 0, 1, 0, 1, 0, 1, 1, 0,
  34. 1, 0, 1, 1, 1, 1, 1, 1, 1
  35. };
  36.  
  37. private readonly double[] _test2Input =
  38. {
  39. 0, 0, 0, 0, 1, 0, 0, 0, 0,
  40. 0, 0, 0, 0, 0, 0, 1, 0, 0,
  41. 0, 1, 0, 0, 1, 0, 0, 0, 1,
  42. 0, 1, 0, 0, 0, 1, 0, 1, 1,
  43. 1, 1, 1, 1, 1, 0, 1, 1, 1
  44. };
  45.  
  46. private readonly double[] _test3Input =
  47. {
  48. 0, 0, 0, 0, 0, 0, 0, 1, 0,
  49. 0, 0, 0, 0, 0, 0, 0, 0, 1,
  50. 1, 1, 0, 0, 0, 0, 0, 0, 1,
  51. 1, 1, 1, 0, 0, 0, 0, 0, 1,
  52. 1, 1, 1, 1, 1, 1, 1, 1, 0
  53. };
  54.  
  55. private readonly double[] _test7Input =
  56. {
  57. 1, 0, 0, 0, 0, 0, 0, 0, 0,
  58. 0, 0, 0, 1, 0, 0, 0, 0, 0,
  59. 1, 0, 0, 1, 0, 0, 0, 1, 0,
  60. 0, 0, 1, 0, 1, 0, 1, 1, 0,
  61. 1, 0, 1, 1, 1, 1, 1, 1, 1
  62. };
  63.  
  64. private readonly double[] _test8Input =
  65. {
  66. 0, 1, 0, 0, 0, 0, 0, 0, 0,
  67. 0, 0, 0, 1, 0, 0, 0, 0, 0,
  68. 0, 0, 0, 0, 1, 0, 1, 0, 1,
  69. 0, 1, 1, 0, 0, 0, 0, 1, 1,
  70. 1, 1, 0, 1, 1, 1, 1, 1, 1
  71. };
  72.  
  73. private readonly double[] _test9Input =
  74. {
  75. 0, 0, 0, 0, 0, 0, 1, 0, 0,
  76. 0, 0, 0, 0, 0, 0, 1, 0, 0,
  77. 0, 0, 0, 0, 1, 1, 1, 0, 0,
  78. 0, 0, 0, 0, 0, 1, 1, 1, 1,
  79. 1, 1, 1, 1, 1, 0, 1, 1, 1
  80. };
  81.  
  82. private readonly double[] _test12Input =
  83. {
  84. 1, 0, 0, 0, 0, 0, 0, 0, 0,
  85. 0, 0, 0, 0, 0, 0, 0, 0, 1,
  86. 1, 0, 0, 0, 1, 0, 1, 0, 0,
  87. 1, 0, 0, 1, 0, 1, 0, 0, 1,
  88. 1, 1, 0, 1, 1, 1, 1, 1, 1
  89. };
  90.  
  91. private readonly double[] _test13Input =
  92. {
  93. 0, 1, 0, 0, 0, 0, 0, 0, 0,
  94. 0, 0, 0, 0, 0, 0, 0, 1, 0,
  95. 0, 1, 1, 0, 0, 0, 1, 0, 0,
  96. 1, 0, 1, 0, 0, 0, 1, 0, 1,
  97. 1, 1, 0, 1, 1, 1, 1, 1, 1
  98. };
  99.  
  100. private readonly double[] _test14Input =
  101. {
  102. 0, 0, 1, 0, 0, 0, 0, 0, 0,
  103. 0, 0, 0, 0, 0, 0, 1, 0, 0,
  104. 0, 0, 0, 0, 1, 1, 1, 0, 0,
  105. 0, 0, 0, 1, 1, 1, 0, 0, 1,
  106. 0, 1, 1, 1, 1, 1, 1, 1, 1
  107. };
  108.  
  109. private readonly double[] _test15Input =
  110. {
  111. 0, 0, 0, 1, 0, 0, 0, 0, 0,
  112. 0, 0, 0, 0, 0, 1, 0, 0, 0,
  113. 1, 0, 1, 0, 0, 0, 1, 0, 0,
  114. 1, 1, 1, 0, 0, 1, 0, 0, 0,
  115. 1, 0, 1, 1, 1, 1, 1, 1, 1
  116. };
  117.  
  118. private readonly double[] _test16Input =
  119. {
  120. 0, 0, 0, 0, 1, 0, 0, 0, 0,
  121. 0, 0, 0, 0, 1, 0, 0, 0, 0,
  122. 0, 0, 0, 1, 1, 0, 0, 1, 0,
  123. 0, 1, 0, 1, 0, 1, 0, 1, 0,
  124. 1, 1, 0, 1, 1, 1, 1, 1, 1
  125. };
  126.  
  127. private readonly double[] _test17Input =
  128. {
  129. 0, 0, 0, 0, 0, 1, 0, 0, 0,
  130. 0, 0, 0, 1, 0, 0, 0, 0, 0,
  131. 1, 1, 0, 0, 0, 0, 0, 1, 0,
  132. 1, 1, 0, 0, 0, 0, 0, 1, 1,
  133. 1, 1, 1, 1, 1, 1, 0, 1, 1
  134. };
  135. //niepoprawne
  136. private readonly double[] _test4Input =
  137. {
  138. 0, 1, 0, 1, 0, 1, 0, 1, 0,
  139. 1, 0, 0, 0, 0, 1, 0, 0, 1,
  140. 1, 1, 0, 0, 0, 0, 1, 0, 1,
  141. 1, 0, 1, 0, 1, 1, 1, 0, 1,
  142. 1, 1, 0, 1, 0, 1, 1, 1, 0
  143. };
  144.  
  145. private readonly double[] _test5Input =
  146. {
  147. 1, 1, 1, 0, 0, 0, 0, 1, 0,
  148. 0, 1, 1, 0, 0, 0, 0, 0, 1,
  149. 1, 0, 0, 1, 0, 1, 0, 0, 1,
  150. 0, 1, 1, 0, 0, 1, 0, 0, 1,
  151. 0, 0, 0, 0, 1, 0, 1, 1, 0
  152. };
  153.  
  154. private readonly double[] _test6Input =
  155. {
  156. 0, 0, 0, 1, 0, 0, 0, 1, 0,
  157. 0, 0, 0, 1, 0, 0, 0, 0, 1,
  158. 1, 1, 0, 1, 0, 0, 1, 0, 1,
  159. 1, 0, 0, 1, 0, 0, 0, 0, 1,
  160. 1, 1, 1, 1, 1, 1, 1, 1, 0
  161. };
  162.  
  163. private readonly double[] _test10Input =
  164. {
  165. 0, 0, 0, 1, 0, 0, 0, 1, 0,
  166. 0, 0, 0, 0, 1, 0, 0, 0, 0,
  167. 0, 1, 0, 1, 0, 0, 1, 0, 0,
  168. 1, 1, 0, 1, 1, 0, 0, 0, 0,
  169. 1, 1, 1, 1, 0, 1, 1, 1, 1
  170. };
  171.  
  172. private readonly double[] _test11Input =
  173. {
  174. 1, 0, 0, 0, 0, 0, 0, 0, 0,
  175. 0, 0, 1, 0, 0, 0, 0, 0, 0,
  176. 1, 1, 0, 1, 0, 0, 1, 0, 1,
  177. 1, 0, 0, 1, 0, 0, 0, 1, 1,
  178. 1, 0, 1, 1, 1, 1, 1, 1, 1
  179. };
  180.  
  181. public readonly double[] _testSuccess =
  182. {
  183. 1//,1,1,1,1
  184. };
  185. private readonly double[] _testFail =
  186. {
  187. 0
  188. };
  189.  
  190. public NeuralNetworkTestData()
  191. {
  192. rand = new Random();
  193. lst = new ArrayList
  194. {
  195. new TestSet(_test1Input, _testSuccess),
  196. new TestSet(_test2Input, _testSuccess),
  197. new TestSet(_test3Input, _testSuccess),
  198. new TestSet(_test4Input, _testFail),//new double[]{0,0,0,0,0}),
  199. new TestSet(_test5Input, _testFail),//new double[]{0,0,0,1,0}),
  200. new TestSet(_test6Input, _testFail),//new double[]{0,0,0,0,1}),
  201. new TestSet(_test7Input, _testSuccess),
  202. new TestSet(_test8Input, _testSuccess),
  203. new TestSet(_test9Input, _testSuccess),
  204. new TestSet(_test10Input, _testFail),//new double[]{0,1,1,0,1}),
  205. new TestSet(_test11Input, _testFail),//new double[]{1,1,0,1,1})
  206. new TestSet(_test12Input, _testSuccess),
  207. new TestSet(_test13Input, _testSuccess),
  208. new TestSet(_test14Input, _testSuccess),
  209. new TestSet(_test15Input, _testSuccess),
  210. new TestSet(_test16Input, _testSuccess),
  211. new TestSet(_test17Input, _testSuccess),
  212. };
  213. }
  214.  
  215. public TestSet GetTestSet()
  216. {
  217. return (TestSet) lst[(rand.Next(1, 17))-1];
  218. }
  219. //public double[] GetTestMatrix()
  220. //{
  221. // int whichTest = rand.Next(1, 3);
  222. // switch (whichTest)
  223. // {
  224. // case 1:
  225. // {
  226. // return _test1Input;
  227. // }
  228. // case 2:
  229. // {
  230. // return _test2Input;
  231. // }
  232. // case 3:
  233. // {
  234. // return _test3Input;
  235. // }
  236. // default:
  237. // {
  238. // return null;
  239. // }
  240. // }
  241. //}
  242.  
  243. //public double[] GetProperResult()
  244. //{
  245. // return _testOutput;
  246. //}
  247. //public void SetTestMatrix(double[] input, double[] resultSet)
  248. //{
  249. // int whichTest = rand.Next(1, 3);
  250. // double[] test = new double[45];
  251.  
  252. // switch (whichTest)
  253. // {
  254. // case 1:
  255. // {
  256. // test = _test1Input;
  257. // break;
  258. // }
  259. // case 2:
  260. // {
  261. // test = _test2Input;
  262. // break;
  263. // }
  264. // case 3:
  265. // {
  266. // test = _test3Input;
  267. // break;
  268. // }
  269. // default :{break;}
  270. // }
  271.  
  272. // input = test;
  273. // resultSet = _testOutput;
  274. //}
  275. }
  276. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement