Advertisement
kyoo0000

Neuro

Mar 15th, 2017
699
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 0.67 KB | None | 0 0
  1. #Funcoes de ativacao representada por φ(υ)
  2.  
  3. ##Funcao de limiar ou delta de dirac
  4. φ₁(υ) = υ >= 0 ? 1 : 0
  5. #Funcao linar por partes
  6. φ₂(υ) = υ ≥ 0.5 ? 1 : (υ ≤ -0.5 ? 0 : υ)
  7. #Funcao logistica onde α e o parametro de inclinacao da funcao sigmoide
  8. φ₃(υ, α) = 1./(1 + exp(*υ))
  9.  
  10. gact(x) = x.*(1-x)
  11.  
  12. function test(iter)
  13.   𝘅 = [0 0 1; 1 1 1; 1 0 1; 0 1 1]
  14.   𝘅ᵀ = transpose(𝘅)
  15.   test = [0, 1, 1, 0]
  16.   weights = 2rand(3, 1) - 1
  17.   for i in 1:iter
  18.     output = φ₃(𝘅 * weights, 1)
  19.     error = test - output
  20.     delta = error.*φ₃(output, 1)
  21.     weights += 𝘅ᵀ * delta
  22.   end
  23.   println(φ₃(𝘅 * weights, 1))
  24. end
  25.  
  26. test(10000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement