how do you access (or store) intermediate results such as weights per epoch in Flux? I have today started using it and was really surprised by how easy it is to implement thing. One thing I did not find and could not solve so far: how do you access results per epoch?
My below minimum working example is doing a simple linear regression. How could I access the weights after epoch i?
I have managed to store losses, however, I am not able to achieve the same for weights.
# Generate simple true data for MWE nFeat = 10 X = rand(nFeat, 200) # rows = features, obs = columns W = transpose(rand(1:10,nFeat)) b = rand(1:10,1) y = W * X .+ b # build simple model for MWE s_in = size(X,1) s_out = 1 m = Flux.Chain( # only one layer for MWE... Dense(s_in, s_out, identity) ) loss(x,y) = Flux.mse(m(x),y) opt = Flux.Descent() my_losses =  evalcb = () -> push!(my_losses, loss(X,y)) # works! # FOR WEIGHTS # my_weights # evalcb = () -> push!(my_weights, [l.W for l in m.layers]) # stores only the final weights # Train model data = [(X,y)] epochs = 1000 for i in 1:epochs if i % 100 == 0 @show i end Flux.train!(loss, Flux.params(m), data, opt, cb=Flux.throttle(evalcb, 10)) end
I could not find anything in the documentation. As I am not an expert on Julia and/or ML it may be due to my lack of understanding, however…
Thanks for your help!