TransWikia.com

Document content getting aligned vertically when pasting algorithm

TeX - LaTeX Asked by AJAY KUMAR SINGH on August 24, 2020

Everything in my document is getting aligned vertically after pasting this algorithm code in my document.

documentclass[a4paper]{article}

 % For reducing margin
usepackage[english]{babel}
usepackage[utf8]{inputenc}
usepackage{algorithm}
usepackage{amsmath}
%usepackage[algo2e]{algorithm2e} 
usepackage{arevmath}     % For math symbols
usepackage{algpseudocode}

title{Algorithm template}
author{Ajay}

date{today}    % Today's date

begin{document}

begin{algorithm}[t]
  centering
  caption{RL-training Algorithm}
  begin{algorithmic}[1]
    Procedure{RL-Training}{Document $D$, Training step $T$, Batch size $B$}
      State Initialize  network params $theta$
      For{$t = 1$ to $T$}
        State Sample input sentence $s_{i}$ from document D  for $i in {1, ldots, B}$
        State Calculate reward value by comparing ROUGE-L score between ground truth summary and predicted summary
        State calculate gradient of loss as begin{equation}
begin{aligned}
nabla L(theta)
& approx-r(hat{y}) sum_{i=1}^{B} nabla log pleft(hat{y}_{i} mid s_{i}, D, thetaright)
end{aligned}
end{equation}
        State Normalize the gradient with Batch size 
        begin{equation}
            g_theta =  frac{1}{B} nabla L(theta)
        end{equation}
        
        State update $theta$ with adam optimizer 
        begin{equation}
            theta gets Call{Adam}{theta, g_{theta}}
        end{equation}
EndFor
  State Return $theta$ newline
  EndProcedure
  end{algorithmic}
end{algorithm}

end{document}

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP