Open fangde opened 2 years ago
It almost work, just for a few issue 1) I need to run 4 times for 4 parameters, I wonder can i get the jacobin in one go.
2) autodiff work, except at the sphere boundary, as there is a big discontinuity. siggraph has a paper about it(https://people.csail.mit.edu/tzumao/diffrt/diffrt.pdf) ,but i don't know how to add it. for example, i want to do manual cacualtiong the gradient myself on the boundary, but use the autodiff gradient eslewhere
Hi @fangde , thanks for the detailed description.
ti.ad.jac
or would like to have the 4 time computation parallel executed? ti.ad.grad_replaced
and ti.ad.grad_for
are designed for this. An example is shown in the doc: https://docs.taichi-lang.org/docs/differentiable_programming#extending-taichi-autodiff-system@erizmr thank you for the reply.
ti.ad.jac
, as to my knowledge , each forward will calculate the loss and dual once, here is a toy example, for real application, I I may have a few hundreds parameters for the scene, in that case to calculate the Jacobin, I will have the overhead of re-render the scene a few hundred times. I think the main benefits of have ti.ad.jac
is performance reason , it will save the overhead of re-render and kernel launch.Hi @fangde
for i, j in ray
inside the kernel is massively paralleled executed, i.e., the overhead of rendering once might not be very high. f(g(h(x)))
, the derivative computed by chain rule is df/dx = df/dg * dg/dh * dh/dx
, you may replace the dg/dh
with manual function. I am wondering if I understand this correctly?
jacobina cacluaiton
I'm trying to use taichi to implement differential ray tracing for various computer vision task. we are using least square to optimized the parameters, needs to calculate the Jacobina,
after a bit research, i managed to get it work, except for a few issues there, someone may have optimization suggestions.
background
The idea is to shot a ray around each pixel, and calculate the intersection of the ray with object. the object can be parametrized, such as the size, and position
based on the measurement data (a photo), we can Calcutta the error between rendered data and measurement, by optimized it against the object parameters, we may correctly estimate the parameters.
I have a test code. ray tracking a sphere, the sphere radius, position are parameters to be optimized . I run once with some parameter, and slightly modify it , render again, caculate the difference, and then use least square optimization to estimate the modifed radius. and postions of the sphere.
trace_loss, find the difference of each pixel
to caculate the jacobin, i use the forward model
and finallly gaussion newton is cacluate in least square manner
if es is correct,should be 0.1