| 13 | |
| 14 | |
| 15 | class LSTM: |
| 16 | def __init__(self, Mi, Mo, activation): |
| 17 | self.Mi = Mi |
| 18 | self.Mo = Mo |
| 19 | self.f = activation |
| 20 | |
| 21 | # numpy init |
| 22 | Wxi = init_weight(Mi, Mo) |
| 23 | Whi = init_weight(Mo, Mo) |
| 24 | Wci = init_weight(Mo, Mo) |
| 25 | bi = np.zeros(Mo) |
| 26 | Wxf = init_weight(Mi, Mo) |
| 27 | Whf = init_weight(Mo, Mo) |
| 28 | Wcf = init_weight(Mo, Mo) |
| 29 | bf = np.zeros(Mo) |
| 30 | Wxc = init_weight(Mi, Mo) |
| 31 | Whc = init_weight(Mo, Mo) |
| 32 | bc = np.zeros(Mo) |
| 33 | Wxo = init_weight(Mi, Mo) |
| 34 | Who = init_weight(Mo, Mo) |
| 35 | Wco = init_weight(Mo, Mo) |
| 36 | bo = np.zeros(Mo) |
| 37 | c0 = np.zeros(Mo) |
| 38 | h0 = np.zeros(Mo) |
| 39 | |
| 40 | # theano vars |
| 41 | self.Wxi = theano.shared(Wxi) |
| 42 | self.Whi = theano.shared(Whi) |
| 43 | self.Wci = theano.shared(Wci) |
| 44 | self.bi = theano.shared(bi) |
| 45 | self.Wxf = theano.shared(Wxf) |
| 46 | self.Whf = theano.shared(Whf) |
| 47 | self.Wcf = theano.shared(Wcf) |
| 48 | self.bf = theano.shared(bf) |
| 49 | self.Wxc = theano.shared(Wxc) |
| 50 | self.Whc = theano.shared(Whc) |
| 51 | self.bc = theano.shared(bc) |
| 52 | self.Wxo = theano.shared(Wxo) |
| 53 | self.Who = theano.shared(Who) |
| 54 | self.Wco = theano.shared(Wco) |
| 55 | self.bo = theano.shared(bo) |
| 56 | self.c0 = theano.shared(c0) |
| 57 | self.h0 = theano.shared(h0) |
| 58 | self.params = [ |
| 59 | self.Wxi, |
| 60 | self.Whi, |
| 61 | self.Wci, |
| 62 | self.bi, |
| 63 | self.Wxf, |
| 64 | self.Whf, |
| 65 | self.Wcf, |
| 66 | self.bf, |
| 67 | self.Wxc, |
| 68 | self.Whc, |
| 69 | self.bc, |
| 70 | self.Wxo, |
| 71 | self.Who, |
| 72 | self.Wco, |
no outgoing calls