Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Funcoes de ativacao representada por φ(υ)
- ##Funcao de limiar ou delta de dirac
- φ₁(υ) = υ >= 0 ? 1 : 0
- #Funcao linar por partes
- φ₂(υ) = υ ≥ 0.5 ? 1 : (υ ≤ -0.5 ? 0 : υ)
- #Funcao logistica onde α e o parametro de inclinacao da funcao sigmoide
- φ₃(υ, α) = 1./(1 + exp(-α*υ))
- gact(x) = x.*(1-x)
- function test(iter)
- 𝘅 = [0 0 1; 1 1 1; 1 0 1; 0 1 1]
- 𝘅ᵀ = transpose(𝘅)
- test = [0, 1, 1, 0]
- weights = 2rand(3, 1) - 1
- for i in 1:iter
- output = φ₃(𝘅 * weights, 1)
- error = test - output
- delta = error.*φ₃(output, 1)
- weights += 𝘅ᵀ * delta
- end
- println(φ₃(𝘅 * weights, 1))
- end
- test(10000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement