latex 算法伪代码右三角注释

在写论文的时候经常要用到伪代码,有时候要对一些算法进行注释更加美观,例如:

对算法加了注释能够使审稿人更明白你的算法内容,那这样的注释应该怎么加?

其实就是一个Comment{} 命令,在开始之前需要导入算法包,这儿就不提示了,我就直接放核心代码

egin{algorithm}[htb]
	caption{ Sparse-attention for Each Window}
	%	label{alg:Framwork}
	egin{algorithmic}[1]
		Require
		Labeled samples ($X$, $Y$) and unlabeled sample $(ar{X}, ar{Y})$. 
		State self-attention feature map S;
		State  randomly select U dot-product pairs from K as $ar{K}$; 	extcolor{blue}{Comment{this is a comment}}
		State set the sample score $ar{S}=Qar{K}$;
		State compute the similarity $M = $Max($ar{S})$ - Mean($ar{S}$)  by rows;
		State set top-$u$ queries under $M$ as $ar{Q}$;
		State set $ S $ = { softmax($ar{Q}K^{T}/sqrt{d}$)$cdot V$, Mean($V$) } by rows;
		
	end{algorithmic}
	
end{algorithm}

展示的结果图:

经验分享 程序员 微信小程序 职场和发展