sharelatex编译后出错,与算法环境有关

sharelatex编译后出错,与算法环境有关

我在 sharelatex 上使用 latex 编写了以下代码:

\begin{algorithm*}[t!]
\small
\caption{Differentially Private Distributed Asynchronous Multi-Task Learning}
\label{alg:dpdamtl}
\begin{algorithmic}
\REQUIRE $T$ databases $\Big\{X_{t},y_{t}\Big\}$ with corresponding loss function $l_{t}$. Parameters $\lambda_1$ and $\lambda_2$.
\ENSURE differentially private models of each task $w_{1},...,w_{T}$.
\STATE Initialize $q_{t}$ in each task node using STL and $p_{t=0}$ the central server, let $S$ be the set which contains indices of the columns of $Q$ that need to be update at each iteration. 
    \FOR {$k = 1,\cdots ,\text{MAX}$}
        \FOR {$\text{task} t, t \in S \subset \[T\}$}
            \STATE Receive $p_{t}^{k-1}$ from central server.
            \STATE Compute objective function $L(q_{t}) = l_{t}(p_{t}^{k-1}+q_{t};X_{t},y_{t}) + \frac{\lambda_1}{2} \|q_{t}\|_{2}^{2}$.
            \STATE Update independent component $q_{t}$: $q_{t}^{k} = q_{t}^{k-1}-\alpha \[ \nabla_{q_{t}} (q_{t})\]$.
            \STATE Denote $\nabla_{p_{t}} l_{t}(p_{t}^{k-1}+q_{t}^{k};X_{t},y_{t}) + \lambda_1 q_{t}^{k} = \nabla_{t}^{k}$ and send $\nabla_{t}^{k}$ to central server immediately.
        \ENDFOR
        \STATE In central server:
            \STATE Receive $\nabla_{t}^{k}, t \in S$ from tasks, build a matrix $\nabla$ such that $\nabla_{t} = \nabla_{t}^{k}, t \in S$ and $\nabla_{t} = \nabla_{t}^{k-1}, t \notin S$.
            \STATE Draw noise parameter $Z$ from $\mathbb{P}$.
            \STATE Compute $P^{k} = \text{prox}_{\lambda_2}^{\|\cdot\|_{*}}(P^{k-1}-\frac{1}{\lambda_2}\nabla) + f(P,Z)$.
            \STATE Send $P_{t}^{k}, t \in S$ to corresponding tasks.
    \ENDFOR
    \FOR {$\text{task} t, t = 1,\cdots , T$}
        \STATE $w_{t} = p_{t} + q_{t}$.
    \ENDFOR
\RETURN $W$.
\end{algorithmic}
\end{algorithm*}

然后编译器给出以下错误:

LaTeX Error: Bad math environment delimiter.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

\GenericError  ...                                
                                                  \endgroup 
\mathdisplay #1->\ifmmode \@badmath 
                                    \else $$\def \@currenvir {#1}\let \dspbr...
<argument> $\text {task} t, t \in S \subset \[
                                              T\}$
\\FOR [#1]#2->\ALC@it \algorithmicfor \ #2
                                          \ \algorithmicdo \ALC@com {#1}\beg...
l.280 ... {$\text{task} t, t \in S \subset \[T\}$}

? 
! Emergency stop.
 ...

谁可以帮我这个事?

答案1

您使用\[代替[。不要忘记\[ ... \]是用于未编号显示的方程式。另外,请注意,您不应使用\cdots表示枚举点,而应使用\ldots。这可以正确编译:

\documentclass[a4paper]{article}
 \usepackage[utf8]{inputenc}
\usepackage{amsmath, amsfonts}
 \usepackage{algorithm, algorithmic}

\begin{document}

\begin{algorithm*}[t!]
\small
\caption{Differentially Private Distributed Asynchronous Multi-Task Learning}
\label{alg:dpdamtl}
\begin{algorithmic}
%\REQUIRE $T$ databases $\Big\{X_{t},y_{t}\Big\}$ with corresponding loss function $l_{t}$. Parameters $\lambda_1$ and $\lambda_2$.
\ENSURE differentially private models of each task $w_{1},...,w_{T}$.
\STATE Initialize $q_{t}$ in each task node using STL and $p_{t=0}$ the central server, let $S$ be the set which contains indices of the columns of $Q$ that need to be update at each iteration.
    \FOR {$k = 1,\ldots ,\text{MAX}$}
 \FOR {$\text{task } t, t \in S \subset T$}
            \STATE Receive $p_{t}^{k-1}$ from central server.
            \STATE Compute objective function $L(q_{t}) = l_{t}(p_{t}^{k-1}+q_{t};X_{t},y_{t}) + \frac{\lambda_1}{2} \|q_{t}\|_{2}^{2}$.
            \STATE Update independent component $q_{t}$: $q_{t}^{k} = q_{t}^{k-1}-\alpha \bigl[ \nabla_{q_{t}} (q_{t})\bigr]$.
            \STATE Denote $\nabla_{p_{t}} l_{t}(p_{t}^{k-1}+q_{t}^{k};X_{t},y_{t}) + \lambda_1 q_{t}^{k} = \nabla_{t}^{k}$ and send $\nabla_{t}^{k}$ to central server immediately.
 \ENDFOR
        \STATE In central server:
            \STATE Receive $\nabla_{t}^{k}, t \in S$ from tasks, build a matrix $\nabla$ such that $\nabla_{t} = \nabla_{t}^{k}, t \in S$ and $\nabla_{t} = \nabla_{t}^{k-1}, t \notin S$.
            \STATE Draw noise parameter $Z$ from $\mathbb{P}$.
            \STATE Compute $P^{k} = \text{prox}_{\lambda_2}^{\lVert\cdot\rVert_{*}}\bigl(P^{k-1}-\frac{1}{\lambda_2}\nabla\bigr) + f(P,Z)$.
            \STATE Send $P_{t}^{k}, t \in S$ to corresponding tasks.
    \ENDFOR
    \FOR {$\text{task } t, t = 1,\ldots , T$}
        \STATE $w_{t} = p_{t} + q_{t}$.
    \ENDFOR
\RETURN $W$.
\end{algorithmic}
\end{algorithm*}

\end{document} 

在此处输入图片描述

相关内容