MCPcopy Index your code
hub / github.com/lazyprogrammer/machine_learning_examples / LSTM

Class LSTM

rnn_class/lstm.py:15–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13
14
15class 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,

Callers 10

translation.pyFile · 0.50
bilstm_test.pyFile · 0.50
bilstm_mnist.pyFile · 0.50
wseq2seq.pyFile · 0.50
lstm1Function · 0.50
lstm2Function · 0.50
attention.pyFile · 0.50
poetry.pyFile · 0.50
lstm_toxic.pyFile · 0.50

Calls

no outgoing calls

Tested by 2

lstm1Function · 0.40
lstm2Function · 0.40