Advertisement
Guest User

Untitled

a guest
Dec 21st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Lab 1
  2. (def n2 (create-net [2 1] :bias true)) ; Создание сети с одним нейроном и двумя входами
  3.  
  4. (def train-set-and
  5.   [[[0 0] [0]] [[0 1] [0]]
  6.    [[1 0] [0]] [[1 1] [1]]])
  7.  
  8. (def train-set-or
  9.   [[[0 0] [0]] [[0 1] [1]]
  10.    [[1 0] [1]] [[1 1] [1]]])
  11.  
  12. (def train-set-vecs
  13.   [[[0.2 0.1] [0]] [[0.3 0.2] [0]]
  14.    [[0.9 0.6] [1]] [[0.9 0.8] [1]]])
  15.  
  16. ; And
  17. (def n2t (training 0.7 0.9 :sigmoid train-set-and 150 n2))
  18.  
  19. (def errors (reverse (:errors n2t)))
  20.  
  21. (def results (vec (apply concat (test-results (map first train-set-and) (:current-s n2t)))))
  22.  
  23. (def my-plot (function-plot (partial nth errors) 0 (dec (count errors-or))))
  24. (view my-plot)
  25.  
  26. ; Or
  27. (def n2t-or (training 0.7 0.9 :sigmoid train-set-or 150 n2))
  28.  
  29. (def errors-or (reverse (:errors n2t-or)))
  30.  
  31. (def results-or (vec (apply concat (test-results (map first train-set-or) (:current-s n2t-or)))))
  32.  
  33. (def my-plot-or (function-plot (partial nth errors-or) 0 (dec (count errors-or))))
  34. (view my-plot-or)
  35.  
  36. ; Vecs
  37. (def n2t-vecs (training 0.7 0.9 :sigmoid train-set-vecs 150 n2))
  38.  
  39. (def errors-vecs (reverse (:errors n2t-vecs)))
  40.  
  41. (def results-vecs (vec (apply concat (test-results (map first train-set-vecs) (:current-s n2t-vecs)))))
  42.  
  43. (def my-plot-vecs (function-plot (partial nth errors-vecs) 0 (dec (count errors-vecs))))
  44. (view my-plot-vecs)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement