MCPcopy Create free account
hub / github.com/chinawithfrank/ChatBotCourse / example_0

Function example_0

lstm_code/nicodjimenez/test2.py:38–67  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36
37
38def example_0():
39 mem_cell_ct = 100
40 x_dim = 50
41 concat_len = x_dim + mem_cell_ct
42 lstm_param = LstmParam(mem_cell_ct, x_dim)
43 lstm_net = LstmNetwork(lstm_param)
44
45 primes = Primes()
46 x_list = []
47 y_list = []
48 for i in range(0, 10):
49 sample = primes.get_sample(x_dim, 1, i)
50 x = sample[0:x_dim]
51 y = sample[x_dim:x_dim+1].tolist()[0]
52 x_list.append(x)
53 y_list.append(y)
54
55 for cur_iter in range(10000):
56 if cur_iter % 1000 == 0:
57 print "y_list=", y_list
58 for ind in range(len(y_list)):
59 lstm_net.x_list_add(x_list[ind])
60 if cur_iter % 1000 == 0:
61 print "y_pred[%d] : %f" % (ind, lstm_net.lstm_node_list[ind].state.h[0])
62
63 loss = lstm_net.y_list_is(y_list, ToyLossLayer)
64 if cur_iter % 1000 == 0:
65 print "loss: ", loss
66 lstm_param.apply_diff(lr=0.01)
67 lstm_net.x_list_clear()
68
69if __name__ == "__main__":
70 example_0()

Callers 1

test2.pyFile · 0.70

Calls 9

get_sampleMethod · 0.95
x_list_addMethod · 0.95
y_list_isMethod · 0.95
apply_diffMethod · 0.95
x_list_clearMethod · 0.95
LstmParamClass · 0.90
LstmNetworkClass · 0.90
PrimesClass · 0.70
appendMethod · 0.45

Tested by

no test coverage detected