# Problems with Flux NN regression

**URL:** <https://discourse.julialang.org/t/problems-with-flux-nn-regression/71714>\
**Category:** Machine Learning\
**Tags:** question, package\
**Created:** [November 18, 2021, 10:17am UTC](https://discourse.julialang.org/t/problems-with-flux-nn-regression/71714 "2021-11-18T10:17:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bitt](https://avatars.discourse-cdn.com/v4/letter/b/67e7ee/32.png) [@Bitt](https://discourse.julialang.org/u/Bitt)\
**Post date:** [November 18, 2021, 10:17am UTC](https://discourse.julialang.org/t/problems-with-flux-nn-regression/71714/1 "2021-11-18T10:17:07Z")

</div>

I am trying to make a regression with NN using Flux. I have separated the dataset in the train/test parts and implemented a simple neural network.

```julia
x_train, x_test, y_train, y_test = train_test_split(convert(Array, x), convert(Array, y), test_size=.3)

nndata = Flux.Data.DataLoader((x_train’, y_train), batchsize=30, shuffle=false)
model = Chain(
Dense(23, 40, relu),
Dense(40, 25, relu),
Dense(25, 1, identity), 
)
ps = Flux.params(model)
loss(x_train, y_train) = Flux.mse(model(x_train), y_train)
opt = ADAM()
using Flux: train!
for i in Array((1:50)’)
train!(loss, ps, nndata, opt)
end
y_pred = model(x_train’)

```

When I train the model, after some epochs, all the predicted value points to a single value, which is close to the mean of y\_train.  
Does anyone have a guess as on what is going on?  
Thank you

---

<div class="post-metadata">

**Author:** ![Rasmus\_Hoier](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rasmus_hoier/32/24036_2.png) [@Rasmus\_Hoier](https://discourse.julialang.org/u/Rasmus_Hoier)\
**Post date:** [November 19, 2021, 7:39am UTC](https://discourse.julialang.org/t/problems-with-flux-nn-regression/71714/2 "2021-11-19T07:39:03Z")

</div>

Hi,  
Not sure what the issue could be, but a starting point could be to look at how the loss is evolving during training. You can use [callbacks](https://fluxml.ai/Flux.jl/stable/training/training/#Callbacks) to monitor this when using the train!() function.

It might also be helpful if you could describe what type of data you are dealing with. Do you have discrete or continuous labels? Is it a balanced dataset?
