I have trouble using package algorithm2e. The following is my latex code:
\begin{algorithm}[H]
\SetAlgoLined
\Comment{Input: Training data S, regularization parameters λ, learning rate η, initialization σ }
\Comment{Output: $\Theta = (w_{0},\textbf{w},\textbf{V})$}
initialization\;
\While{stopping criterion is not met}{
\For{\ (x,y) \in S}
{
w_{0}\leftarrow w_{0}-$η$(\frac{\partial}{\partialw_{0}}l(y(x|\Theta),y) +2\lambda^{0}w_{0});
}
\For{\ i \in \{1,...p\} \wedge x_{i} \neq 0 }
{
w_{i}\leftarrow w_{i} - $η$(\frac{\partial}{\partialw_{i}}l(y(x|\Theta),y)+2\lambda_{\pi}^{w}w_{i});
}
For{ f \in \{1,...k\} }
{
v_{i,f}\leftarrow v_{i,f}-$η$(\frac{\partial}{\partialv_{i,f}l(y(x|\Theta),y)+2\lambda_{f,\pi(i)}^{v}v_{i,f});
}
}
}
\caption{Stochastic gradient descent}
\end{algorithm}
I met such an error as title, the result should be this, thank you.
Best Answer
The following replicates the expected output:
Some considerations:
Input and output can be specified using
\KwIn
and\KwOut
, respectively.Math object that should be bold (like vectors) are typically set using
\mathbf
(or\bm
, needs\usepackage{bm}
after\usepackage{amsmath}
).Use
\repeat
rather than\while
in order for the loop condition to be specified at the end.Math mode is required for math-related content. This often goes for unicode input like λ, η and σ.
Use
\mid
instead of|
to provide conditional functionality.Nest
\For
s to have their structure tier in the output.Use
\dots
rather than ellipses...
inside math.