I have two given vectors $u \in \mathbb{R}^n$ and $v \in \mathbb{R}^n$. I have the following application $f(X) = u^TXv $. I want to calculate its gradient w.r.t to X (which is supposed to be symmetric definite positive). So i did the following : $$u^TXv = trace(u^TXv)= trace((uv^T)^T X) $$Hence I get the following : $$\nabla f(X) = uv^T$$ But since $u^TXv= v^TXu$, I could also have obtained $$\nabla f(X) = vu^T $$
So what is the right answer ?
The convention you choosed for the gradient w.r.t. X need not to change once fixed . First you considered $\nabla_X f(X)=(\nabla_{x_{i,j}} f(X))_{i,j}$ and then you changed $\nabla_{X^T} f(X)=(\nabla_{x_{j,i}} f(X))_{i,j}$ .