Here is the sample code for my training loop
function train()
@showprogress for i in 1:10
l, grads = Flux.withgradient(m -> lossfn(m(X), Y), model)
fmap(model, grads[1]) do p, g
p .= p .- η .* g
end
println(l)
end
end
I am able to capture the loss while computing the gradients. However I also want to say log my predictions generated in the m(X) call. For example I might want to write them to a file. What is the idiomatic way of doing this?
I can modify lossfn to do it inside there but it doesn’t seem clean. Is there a way to return multiple values with Flux.withgradient?
Thanks!