# Flux Learning basics

**URL:** <https://discourse.julialang.org/t/flux-learning-basics/17946>\
**Category:** New to Julia\
**Created:** [November 24, 2018, 4:08pm UTC](https://discourse.julialang.org/t/flux-learning-basics/17946 "2018-11-24T16:08:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Antonio\_Loureiro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/antonio_loureiro/32/15257_2.png) [@Antonio\_Loureiro](https://discourse.julialang.org/u/Antonio_Loureiro)\
**Post date:** [November 24, 2018, 4:08pm UTC](https://discourse.julialang.org/t/flux-learning-basics/17946/1 "2018-11-24T16:08:00Z")

</div>

I’m trying to understand the basics of Flux, it looks really interesting!  
But i’m stuck with a very simple problem, the model is not learning, please check the code below, the model does not update the params and so the loss is always the same. It must be something really simple that i’m forgetting to do.

> df=DataFrame()  
> n=100  
> df[:A]=rand(n)\*100  
> df[:B]=rand(n)\*100  
> df[:C]=rand(n)\*100  
> df[:Y]=df[:A]\*3+df[:B]\*2+df[:C]+rand()\*10  
> data=map(x-\>([x[:A],x[:B],x[:C]],x[:Y]),eachrow(df))

> W = param(rand(1,3))  
> b = param([0.])  
> model(x) = W\*x .+ b  
> loss(x) = (model(x[1])[1])-x[2])^2  
> opt = SGD([W,b])

> for e in 1:30  
> Flux.train!(loss, data, opt)  
> println(sum(map(x-\>loss(x),data)))  
> end
