Error while trying to replicate a logistic regression problem using FluxML

Hi,

I have been trying to replicate the code from the following link to understand how to use ML in Julia better
https://akaysh.github.io/Logistic-Regression-with-Julia/

While replicating I realized that when I ran the following code:

data = repeated((X, y), 200)
Flux.train!(loss, data, opt, cb = evalcb)

the result was this:
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)
loss(X, y) = 0.6931471805599452 (tracked)

As you can see there is no change in the loss function.
Could anyone help me with what the problem is?

Thanks

@akaysh

Hi, im trying to do the same tutorial and I think the problem comes from the predict(x) function, when I’m writing it down in juno, I get the next error

StringIndexError(“predict(x) = NNlib.σ.(”, 21) string_index_err(::String, ::Int64) at string.jl:12
getindex(::String, ::UnitRange{Int64}) at string.jl:246
fuzzycompletionadapter(::String, ::String, ::String, ::Int64, ::Int64, ::Bool) at completions.jl:130
(::getfield(Atom, Symbol(“##279#280”)))(::Dict{String,Any}) at completions.jl:54
handlemsg(::Dict{String,Any}, ::Dict{String,Any}) at comm.jl:169
(::getfield(Atom, Symbol(“##31#33”)){Array{Any,1}})() at task.jl:259

Once I write the second point in the function

predict(x) = NNlib.σ.(x*W .+ b)
.-…-…-…-…-…-…^ Here

But don’t know how to solve it.

Hope bumping this thread someone could help us :pray:.

Looks like a unicode bug

Did you try the following

predict(x) = σ.(x*W .+ b)

?
That should work if you have Flux in scope.

What OS are you using?

Thanks, but the error continues but is actually when I open the parenthesis and not when the second “.” dot is wrote. Withoute the dot, I got an error when trying to run the Flux.train function about broadcasting with σ.(x).

My OS is Linux Mint 19.

Really weird. Because it looks more like you’re struggling with finding the sigma symbol rather than anything else I’ll suggest a few things to try.

https://github.com/FluxML/NNlib.jl/blob/master/src/activation.jl
Try using the fn call sigmoid() instead of the symbol?
NNlib I believe is loaded into Flux but you should be able to load it in yourself by adding it.

Make sure you are using a recent version of Julia 1.0+, and that you have a recent version of Flux.

Otherwise, you may need to post more code with explicit error messages. For reference, this function is working fine for me, and has been for a long time.

1 Like