def __call__(self, x):
z = self.W_z(x)
h_bar = self.W(x)
if self.h is not None:
r = F.sigmoid(self.W_r(x) + self.U_r(self.h))
z += self.U_z(self.h)
h_bar += self.U(r * self.h)
z = F.sigmoid(z)
h_bar = F.tanh(h_bar)
if self.h is not None:
h_new = F.linear_interpolate(z, h_bar, self.h)
else:
h_new = z * h_bar
self.h = h_new # save the state
return h_new
评论列表
文章目录