def recurrent_as_activation_function(self, Wix, Uix, h_tm1, c_tm1, y_tm1):
""" Implement the recurrent unit as an activation function. This function is called by self.__init__().
:param Wix: it equals to W^{hx}x_{t}, as it does not relate with recurrent, pre-calculate the value for fast computation
:type Wix: matrix
:param h_tm1: contains the hidden activation from previous time step
:type h_tm1: matrix, each row means a hidden activation vector of a time step
:param c_tm1: this parameter is not used, just to keep the interface consistent with LSTM
:returns: h_t is the hidden activation of current time step
"""
h_t = T.tanh(Wix + T.dot(h_tm1, self.W_hi) + T.dot(y_tm1, self.W_yi) + self.b_i) #
# simple recurrent decoder
#y_t = T.dot(h_t, self.U_hi) + self.b
# recurrent output and additional input
y_t = Uix + T.dot(h_t, self.U_hi) + T.dot(y_tm1, self.U_yi) + self.b
c_t = h_t
return h_t, c_t, y_t
评论列表
文章目录