We seek the minimum of the function $f:(D_1,D_2)\in\Delta^2\rightarrow trace((D_1AD_2-J)(D_2A^TD_1J))$ where $\Delta$ is the space of diagonal matrices (of course, we use the Frobenius norm). $\dfrac{\partial f}{\partial D_1}:H\in \Delta\rightarrow trace((U+U^T)H)$ where $U=AD_2(D_2A^TD_1-J)$ and $\dfrac{\partial f}{\partial D_2}:H\in \Delta\rightarrow trace((V+V^T)H)$ where $V=A^TD_1(D_1AD_2-J)$. Let $D_1=diag(\lambda_i),D_2=diag(\mu_i),A=[a_{i,j}]$. The conditions $\dfrac{\partial f}{\partial D_1}=\dfrac{\partial f}{\partial D_2}=0$ give the $2n$ equations: for every $i$, $U[i,i]=V[i,i]=0$ in the $2n$ unknowns $(\lambda_i)_i,(\mu_i)_i$. In fact there are only $2n-1$ unknowns because we can choose (for example) $\lambda_1=1$. The $2n$ equations have degree $3$ and can be written as follows: for every $i$, $\sum_ja_{i,j}\mu_j(a_{i,j}\mu_j\lambda_i-1)=0,\sum_ja_{j,i}\lambda_j(a_{j,i}\lambda_j\mu_i-1)=0$. If $n=3$ (resp. $4$), using the Grobner basis theory, we must solve a polynomial of degree $39$ (resp. $284$). It may be better to use a numerical method. But how to choose the initial point ?