奇怪的“\bfseries 在数学模式下无效”问题

奇怪的“\bfseries 在数学模式下无效”问题

我正在编译附录文件作为报告的一部分。我已经完成了文件,有趣的是,当我编译主文件时,它工作正常,但如果我犯了一个错误,导致“bfseries 在数学模式下无效”,我将永远无法摆脱它。我没有在代码中的任何地方明确使用 bfseries,并且我只在数学和文本模式下分别使用了一次 mathbf 或两次 textbf。一旦错误发生一次,我必须删除错误最初出现时我正在编写的 Appdendix 中的部分代码,然后重新运行代码,一旦它正常工作,我复制回已删除的部分,它就会再次正常工作。

可能出了什么问题?

我已将这一节发布在这里,它有点长。我不确定如何获得一个最小工作示例。嗯,那是因为很难看出到底哪里出了问题。

问题是这个部分确实有效。但是当我提到的错误出现时,我必须删除这个特定的部分 -> 运行 -> 重新添加该部分 -> 运行,然后它又可以正常工作了。

\textbf{Calculation of} $\mathrm{H} [p(m_{ij} | \mathcal{D})]$ \\
Since $m_{ij}$ is a binary outcome, $\mathrm{H}[...]$ is just a binary entropy function. The difficult part lies in computing $p(m_{ij} | \mathcal{D})$, the predictive distribution for $m_{ij}$. According to \citep[eq.(4.153)]{ref2}, we can approximate $p(m_{ij} | \mathcal{D})$ using the following result:
\begin{align} %first line of equations
p(m_{ij}=1|\mathcal{D}) &= \iint p(m_{ij}=1|U,V,\mathcal{D}) p(U,V|\mathcal{D}) \mathrm{d}U \mathrm{d}V \nonumber\\ %equation 1
&= \iint \sigma(u_i v_j^T) p(U,V|\mathcal{D}) \mathrm{d}U \mathrm{d}V \ldots \text{from } \eqref{eqn:pmuvdef} \nonumber\\
&\approx \iint \sigma(u_i v_j^T) Q(U,V) \mathrm{d}U \mathrm{d}V \ldots \text{definition of } Q(U,V) \nonumber\\
&\approx \int \sigma(t) \mathcal{N} (t | \mu_0, \sigma_0^2) \mathrm{d}t \ldots \text{let } t=u_i v_j^T \nonumber\\
&\approx \sigma(\kappa(\sigma_0^2) \mu_0) \ldots \text{from } \citep[\text{eq.}(4.153)]{ref2} \label{eqn:pm1} \\
\text{where }& %equation 2
\begin{cases}
\kappa(\sigma_0^2) = (1 + \frac{\pi \sigma_0^2}{8})^{-\frac{1}{2}} \ldots \text{from } \citep[\text{eq.}(4.153)]{ref2} \\
\mu_0 = {\bar{u}}_i {\bar{v}}_j^T \ldots \text{from } \eqref{eqn:uvdistribution} \\
\sigma_0^2 = \mathrm{Trace}[({\bar{u}}_i^T {\bar{u}}_i + \Psi_i) ({\bar{v}}_j^T {\bar{v}}_j + \Phi_j)] \ldots \text{from } \eqref{eqn:uvdistribution}
\end{cases} \label{eqn:pm1c}
\end{align}
Now it is easy to calculate the binary entropy function:
\begin{align} %first line of equations
\mathrm{H}[p(m_{ij} | \mathcal{D})] &= - p(m_{ij}=1|\mathcal{D}) \log{p(m_{ij}=1|\mathcal{D})} - (1-p(m_{ij}=1|\mathcal{D})) \log{(1-p(m_{ij}=1|\mathcal{D}))} \label{eqn:entropy1} \\
\text{where }& p(m_{ij} = 1 | \mathcal{D}) \text{ can be computed using } \eqref{eqn:pm1} \text{ and } \eqref{eqn:pm1c} \nonumber \text{.}
\end{align}
\textbf{Calculation of} $\mathbb{E}_{p(U,V|\mathcal{D})} \left[ \mathrm{H}[p(m_{ij}|U,V,\mathcal{D})] \right] $ \\
Although $\mathrm{H}[p(m_{ij}|U,V,\mathcal{D})]$ can be obtained exactly, the fact that it involves logistic functions means it is impossible to integrate it w.r.t. $p(U,V|\mathcal{D})$. A practical approach, mentioned in \citep[p. 2, Supplementary Material]{ref3}, can be used to approximate the likelihood probability into an exponential form.

Similar to \eqref{eqn:entropy1}, we have:
\begin{equation} \label{eqn:entropylike}
\mathrm{H}[p(m_{ij} | U,V,\mathcal{D})] = - \sigma(u_i v_j^T) \log{\sigma(u_i v_j^T)} - (1-\sigma(u_i v_j^T)) \log{(1-\sigma(u_i v_j^T))}
\end{equation}
Hence $\mathrm{H}[p(m_{ij}|U,V,\mathcal{D}]$ is a function of $\sigma(u_i v_j^T)$ only:
\begin{align} %first line of equations
\text{Define }& %equation 1
\begin{cases}
h(\sigma(x_{ij})) &= \mathrm{H}[p(m_{ij}|U,V,\mathcal{D})] \ldots x_{ij}=u_i v_j^T \\ 
f(x_{ij}) &= \log{h(\sigma(x_{ij}))}
\end{cases} \\
\Rightarrow f(x_{ij}) &= f(0) + \frac{f'(0) x_{ij}}{1!} + \frac{f''(0) x_{ij}^2}{2!} + \ldots \leftarrow \text{Taylor expansion} \label{eqn:taylor} %equation 2
\end{align}
And from \eqref{eqn:entropylike}:
\begin{align} %first line of equations
f'(x_{ij}) &= -\frac{\sigma'(x_{ij})}{h(\sigma(x_{ij}))} (\log{\sigma(x_{ij})} - \log{[1-\sigma(x_{ij})]}) \nonumber\\ %equation 1
\begin{split}
f''(x_{ij}) &= -\frac{\sigma'(x_{ij})}{h(\sigma(x_{ij}))} (\frac{\sigma'(x_{ij})}{\sigma(x_{ij})} + \frac{\sigma'{(x_{ij})}}{[1-\sigma(x_{ij})]}) \\
& \quad + \left( \log{\sigma(x_{ij})} - \log{[1-\sigma(x_{ij})]} \right) \frac{-h(\sigma (x_{ij})) \sigma''(x_{ij}) + \sigma'(x_{ij}) h'(\sigma (x_{ij}))}{h^2 (\sigma(x_{ij}))}
\end{split} \nonumber\\ %equation 2
\Rightarrow&
\begin{cases} %equations 3
f(0) = \log{\log{2}} \\
f'(0) = 0 \\
f''(0) = -\frac{1}{4\log{2}}
\end{cases} \label{eqn:f0set}
\end{align}
Using \eqref{eqn:taylor} and \eqref{eqn:f0set}, $f(x_{ij})$ can be approximated up to second order:
\begin{align} %first line of equations
f(x_{ij}) &\approx f(0) + \frac{f'(0) x_{ij}}{1!} + \frac{f''(0) x_{ij}^2}{2!} \nonumber\\ %equation 1
&\approx \log{\log{2}} - \frac{1}{8\log{2}} x_{ij}^2 \nonumber\\
\Rightarrow \log{h(\sigma(x_{ij}))} &\approx \log{\log{2}} - \frac{1}{8\log{2}} x_{ij}^2 \nonumber\\ %equation 2
\Rightarrow h(\sigma(x_{ij})) &\approx \log{2} \exp{[- \frac{x_{ij}^2}{8\log{2}}]} \label{eqn:htay} %equation 3
\end{align}
Equation \eqref{eqn:htay} gives the required exponential form for $\mathrm{H}[p(m_{ij}|U,V,\mathcal{D})]$, so now it is possible to integrate w.r.t. posterior $p(U,V|\mathcal{D})$.
\begin{align} %first line of equations
\text{Make things simple looking: } h(\sigma(u_i v_j^T)) &\approx k \exp{[c (u_i v_j^T)^2]} \\ %equation 1
\text{where }& k = \log{2}, c = -\frac{1}{8\log{2}} \nonumber\\ %equation 2
\Rightarrow \mathbb{E}_{p(U,V|\mathcal{D})} \left[ \mathrm{H}[p(m_{ij}|U,V,\mathcal{D})] \right] &= \iint h(\sigma(u_i v_j^T)) p(U,V|\mathcal{D}) \mathrm{d}U \mathrm{d}V \nonumber\\ %equations 3
&= \int h(\sigma(t)) \mathcal{N}(t| \mu_0 \sigma_0^2) \mathrm{d}t \ldots t=u_i v_j^T \nonumber\\
&= k \int e^{ct^2} \frac{1}{\sqrt{2\pi \sigma_0^2}} e^{-\frac{(t-\mu_0)^2}{2\sigma_0^2}} \mathrm{d}t  \nonumber\\
&= k \int \frac{1}{\sqrt{2\pi \sigma_0^2}} e^{-\frac{(1-2\sigma_0^2 c)^2 t^2 - 2\mu_0 t + \mu_0^2}{2\sigma_0^2}} \mathrm{d}t \label{eqn:entropy2t1}
\end{align}
Completing the square in t in \eqref{eqn:entropy2t1} gives:
\begin{align} %first line of equations
\mathbb{E}_{p(U,V|\mathcal{D})} \left[ \mathrm{H}[p(m_{ij}|U,V,\mathcal{D})] \right] &= \frac{\sigma_N k}{\sigma_0} \int \left( \frac{1}{\sqrt{2\pi \sigma_N^2}} e^{-\frac{(t-\mu_N)^2}{2\sigma_N^2}} \right) e^{\frac{\mu_N^2}{2\sigma_N^2} - \frac{\mu_0^2}{2\sigma_0^2}} \mathrm{d}t \nonumber\\ %equation 1
&= \frac{\sigma_N k}{\sigma_0} \times 1 \times e^{\frac{\mu_N^2}{2\sigma_N^2} - \frac{\mu_0^2}{2\sigma_0^2}} \\ 
\text{where }&
\begin{cases} 
\mu_N = \frac{\mu_0}{1-2\sigma_0^2 c} \\
\sigma_N^2 = \frac{\sigma_0^2}{1-2\sigma_0^2 c}
\end{cases} \nonumber\\ %equation 2
\Rightarrow \mathbb{E}_{p(U,V|\mathcal{D})} \left[ \mathrm{H}[p(m_{ij}|U,V,\mathcal{D})] \right] &= \frac{k}{\sqrt{1-2\sigma_0^2 c}} \exp{\left[\frac{-\mu_0^2 c}{1-2\sigma_0^2 c}\right]} \nonumber\\ %equation 3
&= \frac{\log{2}}{\sqrt{1-2\sigma_0^2 c}} \exp{\left[\frac{-\mu_0^2 c}{1-2\sigma_0^2 c}\right]} \label{eqn:entropy2} \\
\text{and }& c = -\frac{1}{8\log{2}} \nonumber
\end{align}
Equation \eqref{eqn:entropy2} is our approximate solution to $\mathbb{E}_{p(U,V|\mathcal{D})} \left[ \mathrm{H}[p(m_{ij}|U,V,\mathcal{D})] \right] $. 

Now it is time to combine the results we have:
\begin{align}
& \quad \mathrm{H} [p(m_{ij} | \mathcal{D})] - \mathbb{E}_{p(U,V|\mathcal{D})} \left[ \mathrm{H}[p(m_{ij}|U,V,\mathcal{D}] \right] \nonumber\\
&= \underbrace{\mathrm{H}[\sigma(\kappa(\sigma_0^2)\mu_0)]}_{H_2} - \underbrace{\frac{\log{2}}{\sqrt{1-2\sigma_0^2 c}} \exp{\left[\frac{-\mu_0^2 c}{1-2\sigma_0^2 c}\right]}}_{H_1} \label{eqn:entropy3}
\end{align}
The last equation \eqref{eqn:entropy3} is the final equation used for a BALD procedure: choose the new entry (i,j) such that \eqref{eqn:entropy3} is maximised. $\mathrm{H}[...]$, in this case, is the binary entropy function. Formulae for $\kappa(), \mu_0, \sigma_0^2$ and $c$ can be found in \eqref{eqn:pm1c} and \eqref{eqn:entropy2}, respectively.

If only $H_2$ is maximised in equation \eqref{eqn:entropy3}, then the algorithm becomes an entropy maximisation (EM) algorithm.

答案1

错误在于您在方程中使用\eqref和的地方:\citep

\text{from } \eqref{eqn:pmuvdef}

应该

\text{from \eqref{eqn:pmuvdef}}

相似地

\text{from }\citep[\text{eq.}(4.153)]{ref2}

应该

\text{from \citep[eq. (4.153)]{ref2}}

相关内容