Hi, I am defining the gradients by using below code but i want to make negative values to zero. I wrote below code but it is not working. could you please help me to modify this
function gf_p(p0::Vector, grad::Vector; r, β, η, fem_params)
if length(grad) > 0
dgdp, = Zygote.gradient(p -> gf_p(p; r, β, η, fem_params), p0)
grad[:] = dgdp
end
map(x-> grad[:]<0 , 0)
-grad
end
what do you mean by modifying dgdp? It seems that there are some errors in calculating the gradients by zygot and they are very small so i want to make them as zero.