Differentiation
The recommended mode of differentation is by Automatic Differentiation using Zygote. Refer to the Zygote docs for this. The API listed below is for numerical differentiation and is very restrictive (and unstable) in its current form. It should only be used as a validation for the gradients from Zygote.
Documentation
RayTracer.ngradient
— Function.ngradient(f, xs::AbstractArray...)
Computes the numerical gradients of f
w.r.t xs
. The function f
must return a scalar value for this to work. This function is not meant for general usage as the value of the parameter δ
has been tuned for this package specifically.
Also, it should be noted that these gradients are highly unstable and should be used only for confirming the values obtained through other methods. For meaningful results be sure to use Float64
as Float32
is too numerically unstable.
RayTracer.numderiv
— Function.numderiv(f, θ)
numderiv(f, θ::AbstractArray)
numderiv(f, θ::Real)
Compute the numerical derivates wrt one of the scene parameters. The parameter passed cannot be enclosed in an Array, thus making this not a general method for differentiation.
This is not a generalized method for getting the gradients. For that please use Zygote. However, this can be used to debug you model, incase you feel the gradients obtained by other methods is sketchy.