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

Function example_0

lstm_code/nicodjimenez/test.py:20–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18 return diff
19
20def example_0():
21 # learns to repeat simple sequence from random inputs
22 np.random.seed(0)
23
24 # parameters for input data dimension and lstm cell count
25 mem_cell_ct = 100
26 x_dim = 50
27 concat_len = x_dim + mem_cell_ct
28 lstm_param = LstmParam(mem_cell_ct, x_dim)
29 lstm_net = LstmNetwork(lstm_param)
30 y_list = [-0.5,0.2,0.1, -0.5]
31 input_val_arr = [np.random.random(x_dim) for _ in y_list]
32
33 for cur_iter in range(100):
34 print "cur iter: ", cur_iter
35 print "input_val_arr=", input_val_arr
36 print "y_list=", y_list
37 for ind in range(len(y_list)):
38 lstm_net.x_list_add(input_val_arr[ind])
39 print "y_pred[%d] : %f" % (ind, lstm_net.lstm_node_list[ind].state.h[0])
40
41 loss = lstm_net.y_list_is(y_list, ToyLossLayer)
42 print "loss: ", loss
43 lstm_param.apply_diff(lr=0.1)
44 lstm_net.x_list_clear()
45
46if __name__ == "__main__":
47 example_0()

Callers 1

test.pyFile · 0.70

Calls 6

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

Tested by

no test coverage detected