Instead of defining sigmoid(z::Array) define sigmoid(z::Real) and then use broadcasting to apply it to the elements of an array: sigmoid.(z) (note the dot, which indicates broadcasting)

This is also the problem you’re facing in your OP. If you were to define sigmoid(z::Array), which (again) you shouldn’t, you’ll need dots everywhere:

function sigmoid(z::Array)
return 1.0 ./ (1.0 .+ exp.(-z))
end

However, it is much better to write

sigmoid(z::Real) = 1.0 / (1.0 + exp(-z))

Even better you can make this function type generic like so:

sigmoid(z::Real) = one(z) / (one(z) + exp(-z))

This way it would also work for number types that are not Float64: It will use the appropriate one element (the identity under multiplication) of that particular element type.