Guest User

Untitled

a guest
May 27th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. -- works ----------------------
  2.  
  3. calcedLayer = foldl' k [] rl
  4. k c n = c `seq` c ++ [updateN n]
  5. updateN n = updateNeuron n (v_inputSum n) (v_state n) (weights n)
  6. v_inputSum n = calcNeuron ll (weights n)
  7. v_state n = sigmoidFunction (v_inputSum n)
  8.  
  9. -- don't work ----------------------
  10. {--
  11. src/Backpropagation.hs:149:22:
  12. Couldn't match expected type `([Neuron], [Neuron])'
  13. against inferred type `[Neuron]'
  14. In the first argument of `foldl'', namely `updateNeuronList'
  15. In the expression: foldl' updateNeuronList ([], ll) rl
  16. In the definition of `calcedLayer':
  17. calcedLayer = foldl' updateNeuronList ([], ll) rl
  18. --}
  19. calcLayer :: [Neuron] -> [Neuron] -> [Neuron]
  20. calcLayer ll rl = calcedLayer where
  21. calcedLayer = foldl' updateNeuronList ([], ll) rl
  22.  
  23. -- update layer of neurons
  24. -- avoiding unneeded laziness
  25. updateNeuronList :: ([Neuron], [Neuron]) -> Neuron -> [Neuron]
  26. updateNeuronList (x, ll) n = x `seq` ll `seq` (tmp, ll) where
  27. v_inputSum = calcNeuron ll (weights n)
  28. v_state = sigmoidFunction v_inputSum
  29. updated = updateNeuron n (v_inputSum) (v_state) (weights n)
  30. tmp = x ++ [updated]
  31.  
  32. -- ----------------------
Add Comment
Please, Sign In to add comment