What would the derivative of this objective function be?

My question comes from image processing community,

In our Machine Learning algorithm, we have a predicted value $D$ and its equivalent ground truth $D^*$

where their difference is: $d_i=D-D^*$.

(Think about each of them as a matrix containing all the pixel values of an image)

Now, our goal is to minimize the following objective function:

$L(D,D^*)=\frac{1}{n}\sum_{i}d_i^2-\frac{1}{2n^2}(\sum_{i} d_i)^2+\frac{1}{n}\sum_{i}[(\nabla_xd_i)^2+(\nabla_yd_i)^2]$

where $\nabla_xd_i$ and $\nabla_yd_i$ are the horizontal and vertical gradients of the difference.

For further details see the paper.

What can be the derivative of $L$ w.r.t. $D\; ?$ $(\frac{\partial L}{\partial D} = ?)$

Actually, I have a headache with the last term.

• When you define $d_i$ as $d_i=D-D^*$ you have an $i$ on the left hand side but not the right. This does not make sense given you later sum over $i$. Also it is not clear what $\nabla_x d_i$ and $\nabla_y d_i$ are (what does $D-D^*$ depend on that you have differentiated with respect to - surely these should be arguments of the function $L$)? – smcc Jul 26 '16 at 11:12
• سلام همشری. معادله ی $d_i=D-D^*$ چرا فقط یه اندیس آزاد داره؟ در ضمن مشتق افقی و عمودی یعنی چی؟ شاید این عباراتو رو کتاب شما تعریف کرده. بهتره تعریفشو بگی اینجا. :) – H. R. Jul 26 '16 at 11:15
• @smcc thanks, there are $n$ couples of $(D,D^*)$ so, $d_i$ is the difference of the $i-th$ couple. – Ali Jul 26 '16 at 11:28
• Actually, this is a copy of the objective equation in a paper. $L$ depends on both $D$ and $D^*$, but we wanna get the derivative of $L$ w.r.t just $D$. – Ali Jul 26 '16 at 11:41