# How to histogram Flux predictions?

**URL:** <https://discourse.julialang.org/t/how-to-histogram-flux-predictions/18194>\
**Category:** Machine Learning\
**Created:** [November 30, 2018, 9:14pm UTC](https://discourse.julialang.org/t/how-to-histogram-flux-predictions/18194 "2018-11-30T21:14:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jstrube](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jstrube/32/525_2.png) [@jstrube](https://discourse.julialang.org/u/jstrube)\
**Post date:** [November 30, 2018, 9:14pm UTC](https://discourse.julialang.org/t/how-to-histogram-flux-predictions/18194/1 "2018-11-30T21:14:10Z")

</div>

I’m training a simple regression network with Flux. I’m still learning about the optimizers, but it seems to work OK. However, when I try to make a histogram of predictions on a new data set, I’m getting

```julia
m(x[:,1:4])
Tracked 1×4 Array{Float64,2}:
 85.1661 46.3603 83.5588 84.8866

histogram(m(x[:,1:4]))
StackOverflowError:

Stacktrace:
 [1] max(::Flux.Tracker.TrackedReal{Float64}, ::Flux.Tracker.TrackedReal{Float64}) at /home/jstrube/.julia/packages/NaNMath/pEdac/src/NaNMath.jl:292 (repeats 80000 times)

```

Has somebody gotten managed to histogram output of a Flux model?

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [November 30, 2018, 11:03pm UTC](https://discourse.julialang.org/t/how-to-histogram-flux-predictions/18194/2 "2018-11-30T23:03:52Z")

</div>

I’m pretty sure I once wrote a type recipe for Tracked arrays, but it must have never entered anyway. Also, though, in this case your array is matrix with one row. In Plots that’s going to behave strangely.

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [November 30, 2018, 11:05pm UTC](https://discourse.julialang.org/t/how-to-histogram-flux-predictions/18194/3 "2018-11-30T23:05:26Z")

</div>

You should be able to just `histogram(vec(m(x[:,1:4]).data))` but I didn’t test it (your mwe is not runnable).

---

<div class="post-metadata">

**Author:** ![jstrube](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jstrube/32/525_2.png) [@jstrube](https://discourse.julialang.org/u/jstrube)\
**Post date:** [November 30, 2018, 11:29pm UTC](https://discourse.julialang.org/t/how-to-histogram-flux-predictions/18194/4 "2018-11-30T23:29:23Z")

</div>

That did the trick! Thank you.
