在tflearn中添加多个LSTM图层

时间:2017-07-23 09:35:46

标签: tensorflow deep-learning lstm tflearn

如何为后续神经网络添加另一个LSTM层?

list=[['Running', '01/01/2017', '9346\n'], ['Running', '02/01/2017', '9972\n'], ['Walking', '03/01/2017', '1653\n'], ['Running', '04/01/2017', '6620\n'], ['Running', '05/01/2017', '3802\n'], ['Walking', '06/01/2017', '1798\n'], ['Walking', '07/01/2017', '1333\n'], ['Walking', '08/01/2017', '755\n'], ['Running', '09/01/2017', '7189\n'], ['Running', '10/01/2017', '4434\n'], ['Running', '11/01/2017', '6486\n'], ['Walking', '12/01/2017', '2469\n'], ['Running', '13/01/2017', '8218\n'], ['Running', '14/01/2017', '8854\n'], ['Walking', '15/01/2017', '1960\n'], ['Running', '16/01/2017', '4981\n'], ['Running', '17/01/2017', '3557\n'], ['Running', '18/01/2017', '5560\n'], ['Walking', '19/01/2017', '2534\n'], ['Running', '20/01/2017', '9806\n'], ['Walking', '21/01/2017', '1063\n'], ['Running', '22/01/2017', '6304\n'], ['Walking', '23/01/2017', '1434\n'], ['Walking', '24/01/2017', '1956\n'], ['Running', '25/01/2017', '3564\n'], ['Running', '26/01/2017', '9284\n'], ['Running', '27/01/2017', '8621\n'], ['Running', '28/01/2017', '3575\n'], ['Running', '29/01/2017', '4607\n'], ['Running', '30/01/2017', '6697\n'], ['Running', '31/01/2017', '9917\n'], ['Walking', '01/02/2017', '2788\n'], ['Running', '02/02/2017', '9451\n'], ['Running', '03/02/2017', '3494\n'], ['Running', '04/02/2017', '5674\n'], ['Running', '05/02/2017', '4392\n'], ['Walking', '06/02/2017', '2364\n'], ['Walking', '07/02/2017', '2443\n'], ['Running', '08/02/2017', '8761\n'], ['Walking', '09/02/2017', '2775\n'], ['Running', '10/02/2017', '7984\n'], ['Running', '11/02/2017', '5648\n'], ['Running', '12/02/2017', '6340\n'], ['Running', '13/02/2017', '6884\n'], ['Walking', '14/02/2017', '601\n'], ['Running', '15/02/2017', '3068\n'], ['Walking', '16/02/2017', '1311\n'], ['Walking', '17/02/2017', '2908\n'], ['Running', '18/02/2017', '5134\n'], ['Running', '19/02/2017', '3002\n'], ['Running', '20/02/2017', '6818\n'], ['Running', '21/02/2017', '4143\n'], ['Running', '22/02/2017', '5898\n'], ['Running', '23/02/2017', '9028\n'], ['Running', '24/02/2017', '9263\n'], ['Running', '25/02/2017', '7412\n'], ['Running', '26/02/2017', '6376\n'], ['Walking', '27/02/2017', '1633\n'], ['Running', '28/02/2017', '3581\n'], ['Running', '01/03/2017', '9886\n'], ['Running', '02/03/2017', '5687\n'], ['Running', '03/03/2017', '9531\n'], ['Running', '04/03/2017', '7476\n'], ['Running', '05/03/2017', '6468\n'], ['Walking', '06/03/2017', '1749\n'], ['Running', '07/03/2017', '9172\n'], ['Running', '08/03/2017', '6349\n'], ['Running', '09/03/2017', '7880\n'], ['Running', '10/03/2017', '4683\n'], ['Running', '11/03/2017', '5774\n'], ['Running', '12/03/2017', '3274\n'], ['Walking', '13/03/2017', '1266\n'], ['Running', '14/03/2017', '8701\n'], ['Running', '15/03/2017', '3282\n'], ['Running', '16/03/2017', '4646\n'], ['Running', '17/03/2017', '6174\n'], ['Walking', '18/03/2017', '688\n'], ['Running', '19/03/2017', '4999\n'], ['Running', '20/03/2017', '7051\n'], ['Walking', '21/03/2017', '1536\n'], ['Running', '22/03/2017', '3021\n'], ['Running', '23/03/2017', '8946\n'], ['Running', '24/03/2017', '3543\n'], ['Running', '25/03/2017', '3282\n'], ['Running', '26/03/2017', '8936\n'], ['Running', '27/03/2017', '4170\n'], ['Walking', '28/03/2017', '873\n'], ['Walking', '29/03/2017', '2482\n'], ['Running', '30/03/2017', '3691\n'], ['Walking', '31/03/2017', '2137\n'], ['Running', '01/04/2017', '8509\n'], ['Walking', '02/04/2017', '2397\n'], ['Running', '03/04/2017', '5860\n'], ['Running', '04/04/2017', '9523\n'], ['Running', '05/04/2017', '3655\n'], ['Running', '06/04/2017', '9255\n'], ['Walking', '07/04/2017', '2162\n'], ['Running', '08/04/2017', '5568\n'], ['Running', '09/04/2017', '9572\n'], ['Running', '10/04/2017', '9082\n'], ['Running', '11/04/2017', '8668\n'], ['Running', '12/04/2017', '8514\n'], ['Walking', '13/04/2017', '451\n'], ['Running', '14/04/2017', '8266\n'], ['Running', '15/04/2017', '7561\n'], ['Walking', '16/04/2017', '1183\n'], ['Running', '17/04/2017', '4972\n'], ['Running', '18/04/2017', '4532\n'], ['Walking', '19/04/2017', '1039\n'], ['Walking', '20/04/2017', '1073\n'], ['Running', '21/04/2017', '8378\n'], ['Running', '22/04/2017', '3931\n'], ['Running', '23/04/2017', '6768\n'], ['Walking', '24/04/2017', '1233\n'], ['Running', '25/04/2017', '9897\n'], ['Running', '26/04/2017', '5018\n'], ['Running', '27/04/2017', '4171\n'], ['Walking', '28/04/2017', '2783\n'], ['Running', '29/04/2017', '8050\n'], ['Walking', '30/04/2017', '1470\n'], ['Running', '01/05/2017', '5637\n'], ['Running', '02/05/2017', '6499\n'], ['Running', '03/05/2017', '7860\n'], ['Running', '04/05/2017', '4341\n'], ['Running', '05/05/2017', '8376\n'], ['Walking', '06/05/2017', '1896\n'], ['Walking', '07/05/2017', '1185\n'], ['Running', '08/05/2017', '6294\n'], ['Running', '09/05/2017', '8504\n'], ['Running', '10/05/2017', '3331\n'], ['Running', '11/05/2017', '9937\n'], ['Walking', '12/05/2017', '2124\n'], ['Running', '13/05/2017', '6069\n'], ['Walking', '14/05/2017', '1113\n'], ['Walking', '15/05/2017', '2138\n'], ['Running', '16/05/2017', '5253\n'], ['Running', '17/05/2017', '4625\n'], ['Running', '18/05/2017', '3768\n'], ['Running', '19/05/2017', '3966\n'], ['Running', '20/05/2017', '4613\n'], ['Walking', '21/05/2017', '2101\n'], ['Running', '22/05/2017', '9543\n'], ['Running', '23/05/2017', '3924\n'], ['Running', '24/05/2017', '3876\n'], ['Running', '25/05/2017', '3400\n'], ['Walking', '26/05/2017', '2170\n'], ['Running', '27/05/2017', '3432\n'], ['Running', '28/05/2017', '4258\n'], ['Running', '29/05/2017', '8389\n'], ['Walking', '30/05/2017', '1321\n'], ['Running', '31/05/2017', '5702\n'], ['Walking', '01/06/2017', '2219\n'], ['Running', '02/06/2017', '4814\n'], ['Walking', '03/06/2017', '694\n'], ['Running', '04/06/2017', '5015\n'], ['Walking', '05/06/2017', '619\n'], ['Running', '06/06/2017', '4447\n'], ['Walking', '07/06/2017', '605\n'], ['Running', '08/06/2017', '7404\n'], ['Walking', '09/06/2017', '785\n'], ['Walking', '10/06/2017', '1832\n'], ['Running', '11/06/2017', '8841\n'], ['Running', '12/06/2017', '6083\n'], ['Running', '13/06/2017', '9731\n'], ['Running', '14/06/2017', '3670\n'], ['Running', '15/06/2017', '7395\n'], ['Running', '16/06/2017', '7178\n'], ['Running', '17/06/2017', '4252\n'], ['Running', '18/06/2017', '3148\n'], ['Running', '19/06/2017', '9543\n'], ['Running', '20/06/2017', '5742\n'], ['Running', '21/06/2017', '5190\n'], ['Walking', '22/06/2017', '636\n'], ['Running', '23/06/2017', '7640\n'], ['Running', '24/06/2017', '8020\n'], ['Walking', '25/06/2017', '2878\n'], ['Walking', '26/06/2017', '2625\n'], ['Running', '27/06/2017', '4937\n'], ['Running', '28/06/2017', '7684\n'], ['Running', '29/06/2017', '3829\n'], ['Running', '30/06/2017', '6563\n'], ['Running', '01/07/2017', '6894\n'], ['Walking', '02/07/2017', '434\n'], ['Running', '03/07/2017', '7773\n'], ['Running', '04/07/2017', '8456\n'], ['Walking', '05/07/2017', '2319\n'], ['Walking', '06/07/2017', '426\n'], ['Walking', '07/07/2017', '1316\n'], ['Running', '08/07/2017', '3202\n'], ['Running', '09/07/2017', '8253\n'], ['Walking', '10/07/2017', '1348\n'], ['Running', '11/07/2017', '8342\n'], ['Walking', '12/07/2017', '2508\n']]
list_r=[]
list_w=[]
list_date=[]
c= 0
x= 0  
len=len(list)
for i in range(0,len):
    b= list[c][1]
    list_date.append(b)
    c += 1

for i in range(0,len):
    if list[x][0]=="Running":
        list_r.append(list[x][1:])
        x += 1

elif list[x][0]=="Walking":
    list_w.append(list[x][1:])
    x += 1
else:

    x += 1
running_dates=[s[0] for s in list_r]
running_steps=[s[1] for s in list_r]
walking_dates=[s[0] for s in list_w]
walking_steps=[s[1] for s in list_w]
walking_steps = map(lambda s: s.strip(), walking_steps)
running_steps = map(lambda s: s.strip(), running_steps)

walkingdict = dict(itertools.izip(walking_dates,walking_steps))
runningdict = dict(itertools.izip(running_dates,running_steps))

print walkingdict

`

1 个答案:

答案 0 :(得分:1)

net = tflearn.lstm(net, 128, return_seq=True)
net = tflearn.lstm(net, 256)

不要忘记在之前的LSTM图层上设置return_seq=True,否则您将收到错误