# Error while trying to replicate a logistic regression problem using FluxML

**URL:** https://discourse.julialang.org/t/error-while-trying-to-replicate-a-logistic-regression-problem-using-fluxml/26408
**Category:** Machine Learning
**Created:** [July 16, 2019, 9:14am UTC](https://discourse.julialang.org/t/error-while-trying-to-replicate-a-logistic-regression-problem-using-fluxml/26408 "2019-07-16T09:14:59Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![richie96](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/richie96/32/9353_2.png) [@richie96](https://discourse.julialang.org/u/richie96)
#### Post date: [July 16, 2019, 9:14am UTC](https://discourse.julialang.org/t/error-while-trying-to-replicate-a-logistic-regression-problem-using-fluxml/26408/1 "2019-07-16T09:14:59Z")

</div>

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/](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

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [July 16, 2019, 9:17am UTC](https://discourse.julialang.org/t/error-while-trying-to-replicate-a-logistic-regression-problem-using-fluxml/26408/2 "2019-07-16T09:17:05Z")

</div>

@akaysh

---

<div class="post-metadata">

### Author: ![pauloat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pauloat/32/16517_2.png) [@pauloat](https://discourse.julialang.org/u/pauloat)
#### Post date: [August 5, 2020, 12:01am UTC](https://discourse.julialang.org/t/error-while-trying-to-replicate-a-logistic-regression-problem-using-fluxml/26408/3 "2020-08-05T00:01:16Z")

</div>

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 🙏.

---

<div class="post-metadata">

### Author: ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)
#### Post date: [August 5, 2020, 12:42am UTC](https://discourse.julialang.org/t/error-while-trying-to-replicate-a-logistic-regression-problem-using-fluxml/26408/4 "2020-08-05T00:42:17Z")

</div>

Looks like a unicode bug

Did you try the following

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

```

?  
That should work if you have Flux in scope.

What OS are you using?

---

<div class="post-metadata">

### Author: ![pauloat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pauloat/32/16517_2.png) [@pauloat](https://discourse.julialang.org/u/pauloat)
#### Post date: [August 5, 2020, 11:51pm UTC](https://discourse.julialang.org/t/error-while-trying-to-replicate-a-logistic-regression-problem-using-fluxml/26408/5 "2020-08-05T23:51:30Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)
#### Post date: [August 23, 2020, 1:31pm UTC](https://discourse.julialang.org/t/error-while-trying-to-replicate-a-logistic-regression-problem-using-fluxml/26408/6 "2020-08-23T13:31:03Z")

</div>

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](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.
