How to histogram Flux predictions?


#1

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

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?


#2

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.


#3

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


#4

That did the trick! Thank you.