当前位置:   article > 正文

论文写作-算法伪代码_论文中的算法伪代码怎么写

论文中的算法伪代码怎么写

1.需要说明输入、输出;
2.方法 (函数) 名可写可不写, 如果被别的方法调用就必须写;
3.需要写出主要步骤的注释;
4.长度控制在 15-30 行;
5.可使用数学式子或对已有数学式子的引用;
6.不重要的步骤可以省略;
7.一般需要进行时间、空间复杂度分析, 并写出配套的 property 以及相应的表格, 以使其更标准.
8.使用Latex编写算法伪代码

例子:

  1. \begin{algorithm}[!htb]
  2. \renewcommand{\algorithmicrequire}{\textbf{Input:}}
  3. \renewcommand{\algorithmicensure}{\textbf{Output:}}
  4. \caption{Multi-label active learning through serial-parallel neural networks}
  5. \label{algorithm: masp}
  6. \begin{algorithmic}[1]
  7. \REQUIRE
  8. data matrix $\mathbf{X}$,
  9. label matrix $\mathbf{Y}$ for query,
  10. query budget $Q$,
  11. cold-start query budget $P$,
  12. number of representative instances $R$,
  13. instance batch size $B_i$,
  14. label batch size $B_l$
  15. \ENSURE
  16. queried instance-label pairs $\mathbf{Q}$, prediction network $\Theta$.
  17. \STATE Initialize the serial-parallel prediction network;
  18. \STATE $\mathbf{Q} = \emptyset$;\\
  19. // Stage 1. Cold start.
  20. \STATE Compute instance representativeness according to Eq. \eqref{equation: dp-representativeness};
  21. \STATE Select the top-$R$ representative instances to reorganize the training set $\mathbf{X}$;
  22. \STATE Update $\mathbf{Q}$ and $\mathbf{Y}'$ by querying $B_l$ labels for each of the top $\lfloor Q / B_l \rfloor$ representative instances;
  23. \STATE Train the prediction network using $\mathbf{X}$ and $\mathbf{Y}'$;\\
  24. // Stage 2. Main learning process.
  25. \REPEAT
  26. \STATE Compute $\hat{\mathbf{Y}}$ using the prediction network and Eq. \eqref{equation: label-prediction};
  27. \STATE Compute label uncertainty according to Eq. \eqref{equation: label-uncertainty};
  28. \STATE Query top-$B_i$ uncertain instance-label pairs to update $\mathbf{Q}$ and $\mathbf{Y}'$;
  29. \STATE Update the prediction network using $\mathbf{X}$ and $\mathbf{Y}'$;\\
  30. \UNTIL{($|\mathbf{Q}| \geq Q$)}
  31. \end{algorithmic}
  32. \end{algorithm}


 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小舞很执着/article/detail/926609
推荐阅读
相关标签
  

闽ICP备14008679号