From 8b298a91384996f03c99fea9025b82b31602a527 Mon Sep 17 00:00:00 2001 From: yangsen <1255370037@qq.com> Date: Fri, 15 Dec 2017 15:10:53 +0800 Subject: [PATCH 1/2] Add activation function to cells' output --- lstm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lstm.py b/lstm.py index b99bfa8..1cc6da8 100644 --- a/lstm.py +++ b/lstm.py @@ -95,7 +95,7 @@ def bottom_data_is(self, x, s_prev = None, h_prev = None): self.state.f = sigmoid(np.dot(self.param.wf, xc) + self.param.bf) self.state.o = sigmoid(np.dot(self.param.wo, xc) + self.param.bo) self.state.s = self.state.g * self.state.i + s_prev * self.state.f - self.state.h = self.state.s * self.state.o + self.state.h = np.tanh(self.state.s) * self.state.o self.xc = xc From 4132745b9e01ebdd11f6ad55cee3c648aa0784ed Mon Sep 17 00:00:00 2001 From: yangsen <1255370037@qq.com> Date: Tue, 19 Dec 2017 14:07:13 +0800 Subject: [PATCH 2/2] Add activation function to cells' output --- lstm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lstm.py b/lstm.py index 1cc6da8..eb6a9ed 100644 --- a/lstm.py +++ b/lstm.py @@ -101,7 +101,7 @@ def bottom_data_is(self, x, s_prev = None, h_prev = None): def top_diff_is(self, top_diff_h, top_diff_s): # notice that top_diff_s is carried along the constant error carousel - ds = self.state.o * top_diff_h + top_diff_s + ds = self.state.o * top_diff_h * tanh_derivative(self.state.s) + top_diff_s do = self.state.s * top_diff_h di = self.state.g * ds dg = self.state.i * ds