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