def fp(self, X, f): s = X.shape sl = s[0] dh = self.num_units hp = np.zeros((dh, 1)) cp = np.zeros((dh, 1)) self.Za = np.zeros((sl, dh)) self.Ia = np.zeros((sl, dh)) self.Fa = np.zeros((sl, dh)) self.Ca = np.zeros((sl, dh)) self.Oa = np.zeros((sl, dh)) self.Ha = np.zeros((sl, dh)) self.Ac = np.zeros((sl, dh)) WzX = np.dot(self.params[0], X.T) WiX = np.dot(self.params[1], X.T) WfX = np.dot(self.params[2], X.T) WoX = np.dot(self.params[3], X.T) for i in range(sl): Pac = self.compute_preactivation(WzX[:, i].reshape(dh, 1), hp, 4, 8) zt = actfn.activation_function(Pac, 'tanh') Pac = self.compute_preactivation(WiX[:, i].reshape(dh, 1), hp, 5, 9) Pac = Pac + self.params[12]*cp it = actfn.activation_function(Pac, 'sigm') Pac = self.compute_preactivation(WfX[:, i].reshape(dh, 1), hp, 6, 10) Pac = Pac + self.params[13]*cp ft = actfn.activation_function(Pac, 'sigm') ct = zt*it + cp*ft Pac = self.compute_preactivation(WoX[:, i].reshape(dh, 1), hp, 7, 11) Pac = Pac + self.params[14]*ct ot = actfn.activation_function(Pac, 'sigm') hct = actfn.activation_function(ct, 'tanh') ht = hct*ot self.Za[i, :] = zt.T.reshape(1, dh) self.Ia[i, :] = it.T.reshape(1, dh) self.Fa[i, :] = ft.T.reshape(1, dh) self.Ca[i, :] = ct.T.reshape(1, dh) self.Oa[i, :] = ot.T.reshape(1, dh) self.Ha[i, :] = hct.T.reshape(1, dh) self.Ac[i, :] = ht.T.reshape(1, dh) hp = ht.reshape(dh, 1) cp = ct.reshape(dh, 1)
def fp(self, X, f): s = X.shape sl = s[0] dh = self.num_units hp = np.zeros((dh, 1)) self.Ac = np.zeros((sl, dh)) WiX = np.dot(self.params[0], X.T) for i in range(sl): self.compute_preactivation(WiX[:, i].reshape(dh, 1), hp) hp = actfn.activation_function(self.Pac, f) self.Ac[i, :] = hp.T.reshape(1, dh) hp = hp.reshape(dh, 1)
def fp(self, X, f): self.compute_preactivation(X) self.Ac = actfn.activation_function(self.Pac, f)
def fp(self, X, f): self.compute_preactivation(X) self.Ach = actfn.activation_function(self.Pach, f) self.Act = actfn.activation_function(self.Pact, f) self.Ac = self.Ach * self.Act + X * (1 - self.Act)