I have the following loss function:
$\vert\vert Y - XBX^{\top} \vert\vert_F^2$
where $Y, X$ and $B$ are square and symmetric matrices and $\vert \vert \cdot \vert \vert$ denotes the Frobenius norm. Which is the derivative of the loss function with respect to $X$?
$$\begin{aligned} &\frac{ ‖ Y - XBX^⊤ ‖_F^2}{ X} \\ &=\frac{ ‖ Y - XBX^⊤ ‖_F^2}{(Y - XBX^⊤)} ∘ \frac{ (Y - XBX^⊤)}{ X} \\ &= [{∆Z}↦2⟨Y - XBX^⊤∣{∆Z}⟩_F] ∘ [{∆X} ↦ XB{∆X}^⊤ + {∆X}BX^⊤] \\ &= [{∆X} ⟼ 2⟨Y - XBX^⊤∣XB{∆X}^⊤ + {∆X}BX^⊤⟩_F] \\ &\text{To get the derivative in tensorial form, we need to move everything except ${∆X}$ to the left.} \\ &= [{∆X} ⟼ 2⟨Y - XBX^⊤∣XB{∆X}^⊤⟩_F + 2⟨Y - XBX^⊤∣{∆X}BX^⊤⟩_F] \\ &= [{∆X} ⟼ ⟨2B^⊤X^⊤(Y - XBX^⊤)∣{∆X}^⊤⟩_F + ⟨2(Y - XBX^⊤)XB^⊤∣{∆X}⟩_F] \\ &= [{∆X} ⟼ ⟨2(Y - XBX^⊤)^⊤XB∣{∆X}⟩_F + ⟨2(Y - XBX^⊤)XB^⊤∣{∆X}⟩_F] \\ &= [{∆X} ⟼ ⟨4(Y - XBX^⊤)XB∣{∆X}⟩_F] \end{aligned}$$