From other sources (e.g. here and here), I have cobbled together an equation with underbraces labelling each part.
I would like to add an underbrace to this part:
\rm{tanh}(W_2x_t + U_2h_{t-1} + b_2)
but whenever I do, I get an error: Missing $ inserted.
In the comments in the MWE below, I include the code I tried that generated the error.
How can I add an underbrace to that part of the equation - it's multiplied by a term that already has an underbrace, if that's a problem?
\documentclass{article}
\usepackage{mathtools}% Loads amsmath
\begin{document}
\[
c_t =
\underbrace{\sigma(W_3 x_t + U_3h_{t-1} + b_3)}_\text{forget gate} c_{t-1} +
\underbrace{\sigma(W_1x_t + U_1h_{t-1} + b_1)}_\text{input gate} \rm{tanh}(W_2x_t + U_2h_{t-1} + b_2)
\]
\end{document}
%\[
% c_t =
% \underbrace{\sigma(W_3 x_t + U_3h_{t-1} + b_3)}_\text{forget gate} c_{t-1} +
% \underbrace{\sigma(W_1x_t + U_1h_{t-1} + b_1)}_\text{input gate} \underbrace{\rm{tanh}(W_2x_t + U_2h_{t-1} + b_2)}_\text{c_{new_t}}
%\]