I’m trying to convert the python code(left) into Julia (right), python code is working fine, but Julia code gave an error at the highlighted line l1_delta = ...:
DimensionMismatch("A has dimensions (4,1) but B has dimensions (4,1)")
Julia full code is here:
# sigmoid function
sigmoid(x::Real, derive::Bool=false) =
(derive==true) ? x*(one(x)-x) : one(x)/(one(x) + exp(-x))
x = [0 0 1; 0 1 1; 1 0 1; 1 1 1]
y = [0 0 1 1]'
syn0 = 2 * rand(3,1)
for iter in (:)(1,10000)
l0 = x
l1 = sigmoid.(l0 * syn0)
l1_error = y - l1
l1_delta = l1_error * sigmoid.(l1,true) # here I get the error
syn0 += l0' * l1_delta
end
println("Output After Training:")
l1