# Derivative of Hadamard product with respect to matrix

I'm trying to calculate this derivative wrt matrix $$F_{i}$$ and simplify the whole expression:

$$\frac{ \partial J_{term 1}}{\partial \mathbf{F_{i}}}= 2 (\sum_{j:G(i,j)=1} (\mathbf{W}_{i,j} \odot(\mathbf{D_{i,j}-\mathbf{F_{i}\mathbf{F_{j}'}}}) \frac{ \partial }{\partial \mathbf{F_{i}}}(\mathbf{W}_{i,j} \odot(\mathbf{D_{i,j}-\mathbf{F_{i}\mathbf{F_{j}'}}}) )))$$

My attempt on the derivative:

$$\frac{ \partial }{\partial \mathbf{F_{i}}} ((\mathbf{W}_{i,j} \odot \mathbf{D_{i,j})- (\mathbf{W}_{i,j}\odot \mathbf{F_{i}\mathbf{F_{j}'})}}) = \frac{ \partial }{\partial \mathbf{F_{i}}}(\mathbf{W}_{i,j} \odot \mathbf{D_{i,j}) - \frac{ \partial }{\partial \mathbf{F_{i}}} (\mathbf{W}_{i,j}\odot \mathbf{F_{i}\mathbf{F_{j}'})}}) = 0 - ((\frac{ \partial }{\partial \mathbf{F_{i}}} (\mathbf{W_{i,j}})\odot \mathbf{F_{i}}\mathbf{F_{j}'})+( \mathbf{W_{i,j}}\odot \frac{ \partial }{\partial \mathbf{F_{i}}}(\mathbf{F_{i}}\mathbf{F_{j}'}))) =- (0 + \mathbf{W_{i,j}}\odot\mathbf{F_{j}'})$$

The dimension don't match. I used Matrix cookbook as a guide. I would appreciate if someone could explain how to differentiate this expression in term of matrix $$F_{i}$$

The expected answer looks like this:

$$\frac{ \partial J_{term 1}}{\partial \mathbf{F_{i}}}= 2 (\sum_{} [-(\mathbf{W_{i,j}} \odot \mathbf{W_{i,j}} \odot\mathbf{D_{i,j}) \mathbf{F_{j}}} +( ( \mathbf{W}_{i,j} \odot \mathbf{W}_{i,j} \odot (\mathbf{F_{i}} \mathbf{F_{j}'}))\mathbf{F_{j}})))$$